JQuery Field Validation
- Adam Reyes
- Posts: 35
- Joined: Tue Mar 04, 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');
}
});
$('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
- Site Admin
- Posts: 1524
- Joined: Thu Jun 07, 2012
Hi Adam,
Please, try the code below:
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');
}
});
-
- Information
-
Who is online
Users browsing this forum: No registered users and 7 guests