First off I'm aware that there are already a few threads on here regarding excluding PO Box addresses but it seems that the majority of them use Jquery and my attempts to replicate them within my platform (prestashop) haven't worked out for me. While this may be the solution I resort to if all else fails I'm hoping to use the pattern input attribute if it's possible.
I've got a regular expression that I wish to use within the pattern attribute however I'm not too familiar with regular expressions. In fact I've only recently come across them.
I'm looking to validate a form based on whether a PO Box address has been inputted. If it has then the form will not submit. After doing some research I've come across the following expression which is said to do what I'm looking for:
^ *((#\d+)|((box|bin)[-. \/\\]?\d+)|(.*p[ \.]? ?(o|0)[-. \/\\]? *-?((box|bin)|b|(#|num)?\d+))|(p(ost)? *(o(ff(ice)?)?)? *((box|bin)|b)? *\d+)|(p *-?\/?(o)? *-?box)|post office (box|bin)|((box|bin)|b) *(number|num|#)? *\d+|(num|number|#) *\d+)
This expression is far too complex for my understanding but looking at it in Regex101 it seems to be doing the opposite of what I'm looking for, I could be misunderstanding but it seems to be validating PO boxes and excluding everything else. Regardless of that I tried it on my form but it seems to make it so that regardless of what is inputted it wont be excepted.
This has lead me to believe that either I've done something wrong or the pattern input field doesn't support such complex expressions or it needs to be in a different syntax if it does.
I'd appreciate some clarification on that matter and recommended steps to take in validating my forms.
Does the pattern input attribute support this type of expression and if not how should I go about validating my forms with it?
And for clarification does this expression validate PO boxes or exclude them and if it validates them how would I go about changing it to do the opposite?
Aucun commentaire:
Enregistrer un commentaire