Zipcode validation

how to write validation  for zip code that allow only certain region zip code

  • 1181
  • More
Replies (9)
    • Hello Kanna !

      First of all, you need to know the rules how to check the given Zipcodes and then apply it to the settings of the Zipcode fields in the Studio->Forms->Persons->Add account, add a new field there, set it as "Mandatory" and set the "Check for " field as a regular expression. Below you may enter the reg expression itself. If it requires more complex checks then it will require the code's changes in the modules/boonex/persons/classes/BxPersonsFormsEntryHelper.php file.

      • i have a array contain some zipcode ,that only allow to zipcode field.how to validate with an array ?

        • How many items has this array? Please provide one example also.

          • suppose 10 zipcode in an array,that zipcode only to allow

            • Then yes, you may pack them into the following condition for the regular expression:

              /(zip1)(zip2)(zip3)/

              • An alternative, if the list is more extensive: create a JavaScript function for the page that loops through the array and returns true when a matched is found or false if it exits the loop without a match. The function could employ a regex if the data is complex. However, if it's a concrete list, then JavaScript doesn't need to use regex; a simple loop will do.

                • What do I need to do if I want to implement signing up of users with scratch code as much as 60,000 units? Want the site to auto validate if the code entered is valid and not used already.

                  • Hello DeDiary !

                    It will require to have the Javascript block which will contain the AJAX request to check the entered ZIP code. And PHP file (or request to some module's method) to process this request.

                    • Thanks

                      Login or Join to comment.