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 also want to prevent the user from sending an empty string and the maximum number of characters to be less than 100.
This is the html <input>:
<input type="text" id="addy" maxlength="100"/>
I'm new to javascript, so I do not know how to create a function that will enable the regex patterns to be adhered to.
Thanks
EDIT
Following the recommendation by kolink I tried this:
<input type="text" style="width:285px" placeholder="Enter A Precise Address" name="address0" id="address"
pattern="[ a-zA-Z0-9,#.-]+" maxlength="100" title="Standard address notation only"/>
This now only works if the other <select> have not been selected. Otherwise it does not pick up the pattern attribute. However the exact same code works as expected on jsfiddle: http://jsfiddle.net/peD3t/7/ but not in the browser. This is the code in pastebin: http://pastebin.com/qQGJ4EK5
Thanks