Page 1 of 1

Phone Number Valadation

Posted: 09 Apr 2014
by Hubbaroo
I'm looking for a method of valadating phone number entries. We need to format like (111) 222-333 x4444.


I have found some great code for the column valadation but nothing with the extension. The extension needs to be optional also.


Thank you.

Re: Phone Number Valadation

Posted: 10 Apr 2014
by Dmitry Kozlov
Hello,

You can validate user input with a regular expression. Sample:

Code: Select all

fd.field('Title').change(function() {
  var patt = /^\(\d{3}\) \d{3}-\d{3} x\d{4}$/g;
  if (!patt.test(fd.field('Title').value())) {
    alert('Incorrect phone number');
  }
});