Regex Patterns For Html5 Text Field
I would like to create a regex pattern in javascript for a html text field that takes an address. So I only want the user to enter [a-z,A-Z,0-9] and only these symbols [,#-.] I als
Solution 1:
HTML5 gives you the pattern
attribute, which allows you to require a certain pattern. In this case, you'd want pattern="[a-zA-Z0-9,#.-]+"
It doesn't matter that older browser don't support this, because you should always validate on the server side.
Post a Comment for "Regex Patterns For Html5 Text Field"