Hi all,
Im trying to, deal with a problem that drives me crazy!
Im useing the following code to chech the fields of a form before
really submitting them:
-------
<script language="JAVAS CRIPT">
function CheckForm()
{
var f = document.regist er;
var error_mes = '';
var submitOK="True" ;
if (f.place.value. length < 3)
{
error_mes = error_mes + "\n - No place.";
SubmitOK = "False";
}
if (f.provi.option s[f.provi.value].value == 0)
{
error_mes = error_mes + "\n - No province.";
SubmitOK = "False";
}
if (f.educa.option s[f.educa.value].value == 0)
{
error_mes = error_mes + "\n - No education.";
SubmitOK = "False";
}
if (f.prof.value.l ength == ' ')
{
error_mes = error_mes + "\n - No profession.";
SubmitOK = "False";
}
if (f.civil.option s[f.civil.value].value == 0)
{
error_mes = error_mes + "\n - No civil.";
SubmitOK = "False";
}
if (f.pass.value.l ength == ' ')
{
error_mes = error_mes + "\n - No password.";
SubmitOK = "False";
}
if (f.pass.value != f.pass_ch.value )
{
error_mes = error_mes + "\n - No password check.";
SubmitOK = "False";
}
if (f.email_1.valu e.length < 4)
{
error_mes = error_mes + "\n - No e-mail.";
SubmitOK = "False";
}
if (f.email_1.valu e != f.email_2.value )
{
error_mes = error_mes + "\n - No e-mail check.";
SubmitOK = "False";
}
if (SubmitOK=="Fal se")
{
alert(error_mes );
return false
}
}
</script>
---------
When i leave all the field empty and don't use the dropdown-boxes,
everything works fine; I get an error message and the form is not
submitted. But when i enter text or use the first three or four field
and leave the others blank, i don't get an errormessage and the data
is submitted.
Can anyone tell me how to deal with it??
Thanx!!
WJ
Im trying to, deal with a problem that drives me crazy!
Im useing the following code to chech the fields of a form before
really submitting them:
-------
<script language="JAVAS CRIPT">
function CheckForm()
{
var f = document.regist er;
var error_mes = '';
var submitOK="True" ;
if (f.place.value. length < 3)
{
error_mes = error_mes + "\n - No place.";
SubmitOK = "False";
}
if (f.provi.option s[f.provi.value].value == 0)
{
error_mes = error_mes + "\n - No province.";
SubmitOK = "False";
}
if (f.educa.option s[f.educa.value].value == 0)
{
error_mes = error_mes + "\n - No education.";
SubmitOK = "False";
}
if (f.prof.value.l ength == ' ')
{
error_mes = error_mes + "\n - No profession.";
SubmitOK = "False";
}
if (f.civil.option s[f.civil.value].value == 0)
{
error_mes = error_mes + "\n - No civil.";
SubmitOK = "False";
}
if (f.pass.value.l ength == ' ')
{
error_mes = error_mes + "\n - No password.";
SubmitOK = "False";
}
if (f.pass.value != f.pass_ch.value )
{
error_mes = error_mes + "\n - No password check.";
SubmitOK = "False";
}
if (f.email_1.valu e.length < 4)
{
error_mes = error_mes + "\n - No e-mail.";
SubmitOK = "False";
}
if (f.email_1.valu e != f.email_2.value )
{
error_mes = error_mes + "\n - No e-mail check.";
SubmitOK = "False";
}
if (SubmitOK=="Fal se")
{
alert(error_mes );
return false
}
}
</script>
---------
When i leave all the field empty and don't use the dropdown-boxes,
everything works fine; I get an error message and the form is not
submitted. But when i enter text or use the first three or four field
and leave the others blank, i don't get an errormessage and the data
is submitted.
Can anyone tell me how to deal with it??
Thanx!!
WJ
Comment