Super Dexta
New Member
- Joined
- Aug 15, 2002
- Messages
- 7,841
Form validation my gee. I yoinked it from somewhere else and now I don't now how to get it to do what I want. Basically it's supposed to check that all the fields in a form have been filled in and give you a little pop-up, and it does that, but if they haven't been filled in it submits the form anyway
it looks like this:
<script type="text/javascript">
function validate_form ()
{
valid = true;
if ( document.form1.nam.value == "" )
{
alert ( "Please fill in the 'Your Name' box." );
valid = false;
}
if ( document.form1.skill.value == "" )
{
alert ( "Please fill in the 'Skill' box." );
valid = false;
}
if ( document.form1.cert.value == "" )
{
alert ( "Please fill in the 'Certificate' box." );
valid = false;
}
if ( document.form1.inst.value == "" )
{
alert ( "Please fill in the 'Institution' box." );
valid = false;
}
if ( document.form1.date.value == "" )
{
alert ( "Please fill in the 'Date' box." );
valid = false;
}
return valid;
}
</script>
and my form thing looks like this:
<form action="addskills.php" method="post" name="form1" onSubmit="return validate_form ( )">
it looks like this:
<script type="text/javascript">
function validate_form ()
{
valid = true;
if ( document.form1.nam.value == "" )
{
alert ( "Please fill in the 'Your Name' box." );
valid = false;
}
if ( document.form1.skill.value == "" )
{
alert ( "Please fill in the 'Skill' box." );
valid = false;
}
if ( document.form1.cert.value == "" )
{
alert ( "Please fill in the 'Certificate' box." );
valid = false;
}
if ( document.form1.inst.value == "" )
{
alert ( "Please fill in the 'Institution' box." );
valid = false;
}
if ( document.form1.date.value == "" )
{
alert ( "Please fill in the 'Date' box." );
valid = false;
}
return valid;
}
</script>
and my form thing looks like this:
<form action="addskills.php" method="post" name="form1" onSubmit="return validate_form ( )">