javascript validation in asp.net 3.5
i hv an aspx page in 3.5 so i want to validate 3 dropdownlist box for date with javascript.......then required field validate and email in correct format checkbox selection dropdown to validate for selection...with javascript....
Niradhip ChakrabortyPosted Mar 30, 2009, 11:47 AM
For email validation you can use following javascript code:
if (!isEmail(document.getElementById("txtEmail3").value))
{
alert("Please Enter a Valid E-Mail Address in Shipping Address");
document.getElementById("txtEmail3").focus();
return false;
}
//Note: txtEmail3 is the id of the textbox
function isEmail(s){
if (s.search(/^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/) == -1){
return false;
}
else{
return true;
}
}
now If you have given as "select date" as the first index and if you are trying to enforce user to select valid date.
you can try this:
if(document.getElementById("cboDate").selectedIndex ==0)
{
alert("Please select the Security Question");
return false;
}
//Note: cboDate is the id of the textbox
I didnt understand the checkbox part.