zil
07-13-2004, 01:38 PM
Hello everyone!
Im trying a simple validation...i have 3 fields and if ever one of the 3 fields is not empty, you need to fill all the 3 fields...in fact its about an application form where a person needs to fill in his Bachelor Degree Title, Grade and University...if ever the person enter his/her Bachelor Title, the person needs to enter a grade and the University attended and so on...well my codes are as follows:
<script language="javascript">
function checkDegree(form)
{
var dTitle, dGrade, dUniv
dTitle = form.B_Degree_Title;
dGrade = form.B_Degree_Grade;
dUniv = form.B_Degree_Univ;
if (dTitle.value != null && dGrade.selectedIndex == 0)
{
alert ("Select a grade for your Bachelor's Degree please.");
return (false);
}
else if (dTitle.value != null && dUniv.value == null)
{
alert ("Fill in a a value for the University field for your Bachelor's Degree please.");
return (false);
}
else if (dGrade.selectedIndex > 0 && dTitle.value == null)
{
alert ("Fill in a a value for the Title field for your Bachelor's Degree please.");
return (false);
}
else if (dGrade.selectedIndex > 0 && dUniv.value == null)
{
alert ("Fill in a a value for the University field for your Bachelor's Degree please.");
return (false);
}
else if (dUniv.value != null && dTitle.value == null)
{
alert ("Fill in a a value for the Title field for your Bachelor's Degree please.");
return (false);
}
else if (dUniv.value != null && dGrade.selectedIndex == 0)
{
alert ("Select a grade for your Bachelor's Degree please.");
return (false);
}
}
</script>
Now the problem is that i have a link and as the person clicks on the link, the validation should run...but im having this error message:
Error:'B_Degree_Title' is null or not an object
The B_Degree_Title is the name of the title text box. Can anyone help me please i would be very grateful, thx.
_______________
Zil.
Im trying a simple validation...i have 3 fields and if ever one of the 3 fields is not empty, you need to fill all the 3 fields...in fact its about an application form where a person needs to fill in his Bachelor Degree Title, Grade and University...if ever the person enter his/her Bachelor Title, the person needs to enter a grade and the University attended and so on...well my codes are as follows:
<script language="javascript">
function checkDegree(form)
{
var dTitle, dGrade, dUniv
dTitle = form.B_Degree_Title;
dGrade = form.B_Degree_Grade;
dUniv = form.B_Degree_Univ;
if (dTitle.value != null && dGrade.selectedIndex == 0)
{
alert ("Select a grade for your Bachelor's Degree please.");
return (false);
}
else if (dTitle.value != null && dUniv.value == null)
{
alert ("Fill in a a value for the University field for your Bachelor's Degree please.");
return (false);
}
else if (dGrade.selectedIndex > 0 && dTitle.value == null)
{
alert ("Fill in a a value for the Title field for your Bachelor's Degree please.");
return (false);
}
else if (dGrade.selectedIndex > 0 && dUniv.value == null)
{
alert ("Fill in a a value for the University field for your Bachelor's Degree please.");
return (false);
}
else if (dUniv.value != null && dTitle.value == null)
{
alert ("Fill in a a value for the Title field for your Bachelor's Degree please.");
return (false);
}
else if (dUniv.value != null && dGrade.selectedIndex == 0)
{
alert ("Select a grade for your Bachelor's Degree please.");
return (false);
}
}
</script>
Now the problem is that i have a link and as the person clicks on the link, the validation should run...but im having this error message:
Error:'B_Degree_Title' is null or not an object
The B_Degree_Title is the name of the title text box. Can anyone help me please i would be very grateful, thx.
_______________
Zil.