JQuery Field Validation

Discussions about Forms Designer for SharePoint 2013 / 2016 and Office 365.
Locked
User avatar
Adam Reyes
Posts: 35
Joined: Tue Mar 04, 2014

05 Dec 2014

I would like to use the following to validate a text field but I'm currently unable to get it to work in FormsDesigner:


$('fd.field[fd_name="Address_x0020_1"]').change(function() {

var pattern = new RegExp('[PO.]*\\s?B(ox)?.*\\d+', 'i');

if ($(this).val().match(pattern)) {

alert('No PO Boxes');

}

});

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

08 Dec 2014

Hi Adam,

Please, try the code below:

Code: Select all

fd.field('Address_x0020_1').change(function() {
	var pattern = new RegExp('[PO.]*\\s?B(ox)?.*\\d+', 'i');
	if (pattern.test(fd.field('Address_x0020_1').value())) {
		alert('No PO Boxes');
	}
});

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 7 guests