PDA

View Full Version : Javascript Validation Quirks and Problems


kona72
03-21-2007, 10:16 PM
Hi All,

I have been working on a Database form for insertion (a fairly large one) and had a sub contractor do some javascript work for me for validation and expanding tables. My problem is I have limited knowledge in Javascript and the method apparently is element referencing system and of course now i am having a problem (SC is no longer available) The issue is intermittent and very hard to replicate. What happens is that when someone attempts to sign up, the password does not match javascript is activated... even if the passwords 100% match! There has also been an issue with first name and email even though the fields are filled out. I am totally at a loss here as he has used from what i can see some pretty advanced Javascripting.

This is a link to the page live right now I cannot post the code as the system says it is too long.....

https://www.saskdietitians.org/online_registration.php

Here is the validation JS



<script language="JavaScript" src="email_chk.js"></script>

<script language="JavaScript">
function show_record()
{
no_of_tables=parseInt(document.signup.no_of_tables .value);
for(k=1; k<=no_of_tables; k++)
{
if(document.getElementById("tr"+k))
{
document.getElementById("tr"+k).style.display="block";
}
else
{
alert("Sorry, DHTML error!!");
}
}

for(i=k;i<=25;i++)
{
document.getElementById("tr"+i).style.display="none";
}

}

function hide_base(S)
{
document.getElementById("tr"+S).style.display="none";
document.getElementById("delete"+S).checked="true";
}

function chk()
{
if(document.signup.elements[13].value=="")
{
alert("Please enter username.");
document.signup.elements[13].focus();
return false;
}
if(document.signup.elements[14].value=="")
{
alert("Please enter password.");
document.signup.elements[14].focus();
return false;
}
if(document.signup.elements[14].value!=document.signup.elements[15].value)
{
alert("Enter password didnot match");
document.signup.elements[15].focus();
return false;
}
if(document.signup.elements[16].value=="")
{
alert("Please enter surname.");
document.signup.elements[16].focus();
return false;
}
if(document.signup.elements[18].value=="")
{
alert("Please enter first name.");
document.signup.elements[18].focus();
return false;
}
if(document.signup.elements[19].value=="")
{
alert("Please enter street address.");
document.signup.elements[19].focus();
return false;
}
if(document.signup.elements[20].value=="")
{
alert("Please enter a city.");
document.signup.elements[20].focus();
return false;
}
if(document.signup.elements[21].value=="--")
{
alert("Please enter your province.");
document.signup.elements[21].focus();
return false;
}
if(document.signup.elements[22].value=="")
{
alert("Please enter your postalcode.");
document.signup.elements[22].focus();
return false;
}
if(document.signup.elements[23].value=="")
{
alert("Please enter your home phone.");
document.signup.elements[23].focus();
return false;
}
if(document.signup.elements[24].value=="")
{
alert("Please enter your email.");
document.signup.elements[24].focus();
return false;
}
if(!checkEmail(document.signup.elements[24].value))
{
document.signup.elements[24].focus();
return false;
}
/*if(document.signup.academic.value=="")
{
alert("Please enter your academic update.");
document.signup.academic.focus();
return false;
}*/
if(document.signup.details.value=="")
{
alert("Please enter your details.");
document.signup.details.focus();
return false;
}
return true;
}
</script>