JQuery Field Validation

rss

Posted by Adam Reyes - Dec 5 ’14 at 04:30

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

}

});

  • Dmitry Kozlov
    Dmitry Kozlov
    Admin
    Member for: 6 years 2 months 18 days
    #1 by Dmitry Kozlov Dec 8 ’14 at 04:48

    Hi Adam,

    Please, try the code below:

    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');
    	}
    });
    
Displaying 1 to 1 of 1 messages