Hey people.. Im creating a form where one of the text input fields needs to hold an address.. For this i need to make sure that the user types at least letters and numbers.. That is all.. I just cant seem to find out how do to this with JavaScript Regular Expression ..
What i have is this
The above is not good enough .. It "works" but only for one type of address like this:Code:<input type="text" size="47" required="true" name="adresse" required pattern="[A-Za-z ]+\d+[A-Za-z \,\.]+\d+[A-Za-z \,\.]+"/>
Sunset road 4C, 1.tv.
Yes thats how an address could look here in Denmark
But i also need it to be able to accept an address like this:
Sunset road 4
or
Sunset road 4-C 1-tv.
or
Sunset road 4 C 1.t-v.
And the list goes on .. The easiest way for this i believe is to just make the regular expression check if there is numbers and letters in the field and thats it .. How do i go about that ?





Reply With Quote