Currently Im developing on a website with Zend framework.
I needed to develop a location field similar to http://www.truelocal.com.au/
Which allow user to input PostCode Values (consist of 4 numbers) or Suburb Name (in the format of Suburb Name comma symbol space State abbreviations (State abbreviations consist exact three letters) )
Example input for Postcode: 2000
Example input for Suburb Name: MANLY, NSW or SYDNEY, NSW or PALM BEACH, QLD
I need the validate the location value to ensure these 2 format
I found out that in Zend framework you can use use Regular Expression in Zend_Validate_Regex for it.
$myValidator = new Zend_Validate_Regex('Regular Expression');
$myValidator->setMessage('Your validation message goes here',Zend_Validate_Regex::NOT_MATCH);
But how can I write a Regular Expression which check in these 2 Regular Expression format (PostCode Values (consist of 4 numbers) or Suburb Name (in the format of Suburb Name comma symbol space State abbreviations (State abbreviations consist exact three letters) ) in just one input field.
In this particular scenario is it feasible to do in Zend_Validate_Regex
If possible can you teach me how to write the Regular expression for it.
Thanks you so much in advance! Very Appreicated!
Thanks for reading and have a good weekend!
Try using this regular expression: