Custom Drop down list "Other" validation
Recently we have had an issue spring up. When we enter numbers into the other field of a drop dawn it will convert to a date when exported to excel. Specically numbers with dashes are represented as a date in excel.
e.g 2 - 3 becomes 3-Feb
Some users have figure out how to get around this by typing in 2 to 3 instead. Going forward I nned to make this a little less trouble for them.
I tried to correct this but I am not having anfy luck. If I can't prevent it I would like to alert them to fix it.
//Race
var options = fd.field('RACE').control()._el().find('td');
var content = '<table>';
content += '<tr>';
content += '<td>' + options.eq(0).html() + '</td>'; //Rows
content += '<td>' + options.eq(5).html() + '</td>'; //Rows
content += '</tr>'
content += '<tr>';
content += '<td>' + options.eq(1).html() + '</td>'; //Rows
content += '<td>' + options.eq(8).html() + options.eq(9).html() + '</td>'; //Rows
content += '</tr>'
content += '<tr>';
content += '<td>' + options.eq(2).html() + '</td>'; //Rows
content += '<td>' + options.eq(6).html() + '</td>'; //Rows
content += '</tr>'
content += '<tr>';
content += '<td>' + options.eq(3).html() + '</td>'; //Rows
content += '<td>' + options.eq(7).html() + '</td>'; //Rows
content += '</tr>';
content += '<tr>';
content += '<td>' + options.eq(4).html() + '</td>'; //Rows
content += '<td></td>'; //Rows
content += '</tr>';
content += '</table>';
fd.field('RACE').control()._el().html(content);
//Race Other Text
$('label[for*=RACEField_ctl00_ctl08]').text('Other, specify');
var alNumRegex = /^([a-zA-Z0-9]+)$/; //only letters and numbers
if(alNumRegex.test(options.eq(9).val())) {
alert("value of myTextbox is an alphanumeric string");
}
Thank you.
e.g 2 - 3 becomes 3-Feb
Some users have figure out how to get around this by typing in 2 to 3 instead. Going forward I nned to make this a little less trouble for them.
I tried to correct this but I am not having anfy luck. If I can't prevent it I would like to alert them to fix it.
//Race
var options = fd.field('RACE').control()._el().find('td');
var content = '<table>';
content += '<tr>';
content += '<td>' + options.eq(0).html() + '</td>'; //Rows
content += '<td>' + options.eq(5).html() + '</td>'; //Rows
content += '</tr>'
content += '<tr>';
content += '<td>' + options.eq(1).html() + '</td>'; //Rows
content += '<td>' + options.eq(8).html() + options.eq(9).html() + '</td>'; //Rows
content += '</tr>'
content += '<tr>';
content += '<td>' + options.eq(2).html() + '</td>'; //Rows
content += '<td>' + options.eq(6).html() + '</td>'; //Rows
content += '</tr>'
content += '<tr>';
content += '<td>' + options.eq(3).html() + '</td>'; //Rows
content += '<td>' + options.eq(7).html() + '</td>'; //Rows
content += '</tr>';
content += '<tr>';
content += '<td>' + options.eq(4).html() + '</td>'; //Rows
content += '<td></td>'; //Rows
content += '</tr>';
content += '</table>';
fd.field('RACE').control()._el().html(content);
//Race Other Text
$('label[for*=RACEField_ctl00_ctl08]').text('Other, specify');
var alNumRegex = /^([a-zA-Z0-9]+)$/; //only letters and numbers
if(alNumRegex.test(options.eq(9).val())) {
alert("value of myTextbox is an alphanumeric string");
}
Thank you.
-
- Moderator
- Posts: 33
- Joined: Wed Sep 21, 2016
Hi! Put this code in Javascript, please:
Code: Select all
fd.onsubmit(function(){
if(!/^([a-zA-Z0-9]+)$/.test(fd.field('RACE').control()._el().find('input[type="text"]').val())) {
alert("value of myTextbox is an alphanumeric string");
return false;}
return true;
});
-
- Information
-
Who is online
Users browsing this forum: No registered users and 3 guests