Custom Drop down list "Other" validation

rss

Posted by Sonoma - Oct 27 ’16 at 11:23

 

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.

 

  • YuriyMedvedev
    Moderator
    Member for: 2 years 11 months 24 days
    #1 by YuriyMedvedev Oct 28 ’16 at 05:51

    Hi! Put this code in Javascript, please:

     

    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;
    });
  • Sonoma
    Member
    Member for: 4 years 11 months 26 days
    #2 by Sonoma Oct 28 ’16 at 05:56

    Thank you. I will give it a try. I was trying to over complicate it by hit one part of it insead of the whole thing.

Displaying 1 to 2 of 2 messages