HTML5 Form Validator Support Product Page
  Not a problem 
 Pattern matching with RegEx
 Reported  16 Aug 2016  14:35:36 
  1 
     has   this problem  
  16 Aug 2016  14:35:36 David Woolley posted: 
 I'm having trouble using pattern matching with RegEx for client-side validation. No problem with the other validations so far.I need to make sure users search for a particular pattern in a code - 4 digits that can include leading zeros for example: 0004 , 0104
I thought that this expression would do it: \d{4}
but no validation occurs. \d\d\d\d lets everything thru as well.
Then I tried quite a few other simple regexes to test the system but all entries are accepted.
Replies
 Replied 17 Aug 2016  09:29:54 
   17 Aug 2016  09:29:54 Teodor Kuduschiev replied: 
  Hi David,
As per your pattern you should use: (^([0-9]{4})$)
  As per your pattern you should use: (^([0-9]{4})$)
 Replied 22 Aug 2016  11:59:13 
   22 Aug 2016  11:59:13 David Woolley replied: 
  Hi Teodor
(^([0-9]{4})$) or ^[0-9]{4}$ still lets anything thru.
For example I can enter "xyz" and the input field does not reject with an error message.
As I said earlier, I've also tested a few other simple regexes with this input field and nothing is rejected.
Number Validation validates perfectly, but obviously with no leading zeros.
  (^([0-9]{4})$) or ^[0-9]{4}$ still lets anything thru.
For example I can enter "xyz" and the input field does not reject with an error message.
As I said earlier, I've also tested a few other simple regexes with this input field and nothing is rejected.
Number Validation validates perfectly, but obviously with no leading zeros.
 Replied 22 Aug 2016  12:08:55 
   22 Aug 2016  12:08:55 Teodor Kuduschiev replied: 
  Hello David,
With the validation pattern i provided "xyz" does not get through ....
 
 
  With the validation pattern i provided "xyz" does not get through ....
 
  Replied 22 Aug 2016  12:44:29 
   22 Aug 2016  12:44:29 David Woolley replied: 
  Thanks Teodor - working now.
In all my troubleshooting, I managed to delete the type = "text" attribute.
Added this back then it validates. But if the input tag does not have a type attribute, it should default to "text" anyway.
Dave
  In all my troubleshooting, I managed to delete the type = "text" attribute.
Added this back then it validates. But if the input tag does not have a type attribute, it should default to "text" anyway.
Dave
