Hi there,
I'm having some trouble validating the choice of my select box with javaScript. Essentially, there are 3 choices ("" with a value of -2, "Approved" with a value of 1 and "Pending" with a value of 0. And when someone chooses the "" (-2) option, I would like to display a message near the select box to notify users that they must pick another choice.
This is my code:
Thanks!
I'm having some trouble validating the choice of my select box with javaScript. Essentially, there are 3 choices ("" with a value of -2, "Approved" with a value of 1 and "Pending" with a value of 0. And when someone chooses the "" (-2) option, I would like to display a message near the select box to notify users that they must pick another choice.
This is my code:
Code:
function setValidationInvalidFundingSrc(msg){
validationMsgInvalidFundingSrc = msg;
}
function fundingStatusLoseFocus(rCounter){
if($('#source_other_Amount_status_'+rCounter).val() == -2){
showErrorMessage(validationMsgInvalidFundingSrc,'#source_other_Amount_status_'+rCounter);
}
}
function showErrorMessage(message,id){
$('#invalidDigit').remove();
$(id).after("<div id='invalidDigit' style='color:red'>"+message+" </div>");
$('#DraftBT').attr('disabled', 'true');
$('#SubmitBT').attr('disabled', 'true');
}
//This is the html from another page
"<td align='center'><select class='required' id='source_other_Amount_status_"+rowCounter+"' name='source_other_Amount_status_"+rowCounter+"' value='Status'><option value='-2' onblur='fundingStatusLoseFocus("+rowCounter+")'></option><option value='1'>"+approved+"</option><option value='0'>"+pending+"</option></select></td>"
Thanks!
Comment