Page 1 of 1

JQuery Field Validation

Posted: 05 Dec 2014
by Adam Reyes
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');

}

});

Re: JQuery Field Validation

Posted: 08 Dec 2014
by Dmitry Kozlov
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');
	}
});