krishnan_sn
01-12-2004, 07:15 AM
hi,
i have written some javascript code to validate the form. but the script code executes some times and prompts for the user to enter the values. some times it skips it. i donot know how to solve this problem. whether i have to change any property in the explorer. iam using IE explorer. i am not sure about the versionof it. or should i change the code.
i have included the code below.
<SCRIPT LANGUAGE=javascript>
<!--
function ValidateId()
{
if(document.frmCreateLogin.txtLogin.value=="")
{
alert("Enter Login ID");
document.frmCreateLogin.txtLogin.focus();
document.frmCreateLogin.txtLogin.select();
return false;
}
else
{
if(!isNaN(document.frmCreateLogin.txtLogin.value))
{
alert("Invalid User ID");
document.frmCreateLogin.txtLogin.select();
return false;
}
}
if(document.frmCreateLogin.txtPass1.value=="")
{
alert("Enter First Password");
document.frmCreateLogin.txtPass1.focus();
return false;
}
if(document.frmCreateLogin.txtpass2.value=="")
{
alert("Enter Confirm Password");
document.frmCreateLogin.txtpass2.focus();
return false;
}
if(document.frmCreateLogin.txtPass1.value != document.frmCreateLogin.txtpass2.value)
{
alert("Both passwords should be same");
document.frmCreateLogin.txtPass1.focus()
document.frmCreateLogin.txtPass1.select()
return false;
}
return true;
}
//-->
</SCRIPT>
i have written some javascript code to validate the form. but the script code executes some times and prompts for the user to enter the values. some times it skips it. i donot know how to solve this problem. whether i have to change any property in the explorer. iam using IE explorer. i am not sure about the versionof it. or should i change the code.
i have included the code below.
<SCRIPT LANGUAGE=javascript>
<!--
function ValidateId()
{
if(document.frmCreateLogin.txtLogin.value=="")
{
alert("Enter Login ID");
document.frmCreateLogin.txtLogin.focus();
document.frmCreateLogin.txtLogin.select();
return false;
}
else
{
if(!isNaN(document.frmCreateLogin.txtLogin.value))
{
alert("Invalid User ID");
document.frmCreateLogin.txtLogin.select();
return false;
}
}
if(document.frmCreateLogin.txtPass1.value=="")
{
alert("Enter First Password");
document.frmCreateLogin.txtPass1.focus();
return false;
}
if(document.frmCreateLogin.txtpass2.value=="")
{
alert("Enter Confirm Password");
document.frmCreateLogin.txtpass2.focus();
return false;
}
if(document.frmCreateLogin.txtPass1.value != document.frmCreateLogin.txtpass2.value)
{
alert("Both passwords should be same");
document.frmCreateLogin.txtPass1.focus()
document.frmCreateLogin.txtPass1.select()
return false;
}
return true;
}
//-->
</SCRIPT>