JS code popping up error
I got this below code from Google for E-mail validation in my js file.
function validateEmail(thefield)
{
alert ('This is the 1st step');
var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
alert ('This is the 2nd step'); **after this i am getting error in explorer**
var address = document.elements[thefield].value;
alert ('going into if loop' + address.value);
if(reg.test(address) == false)
{
alert('Invalid Email Address');
开发者_StackOverflow return false;
}
}
Please let me know what modifications are required in this to make it work??
HTML code:
<form action="pageserver" method="post" id="inputForm" target="_parent" onsubmit="return(onSubmit());">
<input type="text" value=" " name="MIR-CLI-CNTCT-ID-TXT-T[1]" stype="Text" maxlength="50" onfocus="enterField(this)" onblur="validateEmail(this)" size="50" />
Thansk sdleihssirhc.
I could find out the error.... and fix it...
the line was having erros, var address = document.elements[thefield].value;
I removed the vairable which was passed in the function and just placed the same variable directly in the required field....
var address = document.all[email].value;
精彩评论