0

I have made pattern for address field, that works well on regex101.com, but when I used it on my page not working? Real problem pattern does not any response.

<form>
   <input type="text" id="address" name="address" title="Address length must be  5 to 60, only one space between address, in start space and special character are not allow " placeholder="Your adress.." pattern="^[^-\s\W&(%#$^)][\da-zA-Z]{4,}+( [\d\Sa-zA-Z]+)*$" maxlength="60" required="required">
   <input type="submit">
</form>
Sunil Garg
  • 14,608
  • 25
  • 132
  • 189
wajid ali
  • 25
  • 1
  • 7
  • can you please remove prefix ^ and suffix $ and try. – Sam Sep 11 '17 at 05:45
  • Are you certain you chose JavaScript flavour of regex on regex101? Have you tried the Rex in the console for any errors (see https://www.raymondcamden.com/2014/01/13/HTML5-Input-Patterns-and-Invalid-Regex/ for more info). Finally, ^ and $ are not required in pattern, according to the spec but this so post indicates some implementations vary or could be broken - https://stackoverflow.com/questions/9142208/should-i-use-and-in-html5-input-regex-pattern-validation – Caius Jard Sep 11 '17 at 05:52
  • Probably this is a glitch: `( [\d\Sa-zA-Z]+)*` means, you want one space followed by one or more characters, plus probably another space with n characters, plus probably another space etc. The asterisk is a multiplier, meaning 0, 1 or multiple occurrences. – Anse Sep 11 '17 at 06:46

0 Answers0