Thursday, February 11

Updating Submit Disable to Include isNaN

The datanumber should be numeric, so I wanted to check on the frontend, before they even submit it. It was easy to add an else to the previous javascript function SearchVal().

function searchVal(){
if(document.getElementById('fname').value == 0
&& document.getElementById('lname').value == 0
&& document.getElementById('datanum').value == 0){
msg = 'At least one search field must be filled';

}else if(isNaN(document.getElementById('datanum').value)){
msg = 'Data number must be numeric';

}else{
dis = false;
msg = '';
}

if(dis == true){
document.getElementById('sub').disabled = true;
}else{
document.getElementById('sub').disabled = false;
}
document.getElementById('validmsg').innerHTML = msg;
}

No comments: