Phone Number Valadation

Discussions about Forms Designer for SharePoint 2013 / 2016 and Office 365.
Locked
Hubbaroo
Posts: 60
Joined: Sat Sep 21, 2013

09 Apr 2014

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.

User avatar
Dmitry Kozlov
Site Admin
Posts: 1524
Joined: Thu Jun 07, 2012

10 Apr 2014

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');
  }
});

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 18 guests