0

Hi,
I don't understand why this validation check isn't work,
Everything is OK, but ....

<html>
<head>
<script type="text/javascript">
function valForm()
{
	var x = document.forms["ActorForm"]["actorfname"].value;
	if (x == null || x == "")
	{
		alert("First name must be filled out");
		return false;
	}
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Actor insert form</title>
</head>

<body>
	<form name="ActorForm" action="Actor_Insert.php" onSubmit="return valFrom()" method="post">
    	Person ID: <input type="text" name="actorid" /> Required<br />
        <input type="radio" name="actorgender" value="male" /> Male<br />
        <input type="radio" name="actorgender" value="female" /> Female<br />
        First Name: <input type="text" name="actorfname" /><br />
        Last Name: <input type="text" name="actorlname" /><br />
        Birthday: <input type="date" name="actorbirthday" /><br />
        <input type="submit" name="actorsubmit" value="Submit" />
    </form>
</body>
</html>
4
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by Airshow
0

here ya go

<html>
<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Actor insert form</title>
</head>

<body>
    <form name="ActorForm" action="Actor_Insert.php" onSubmit="return valForm()" method="post">
        Person ID: <input type="text" name="actorid" /> Required<br />
        <input type="radio" name="actorgender" value="male" /> Male<br />
        <input type="radio" name="actorgender" value="female" /> Female<br />
        First Name: <input type="text" name="actorfname" /><br />
        Last Name: <input type="text" name="actorlname" /><br />
        Birthday: <input type="date" name="actorbirthday" /><br />
        <input type="submit" name="actorsubmit" value="Submit" />
    </form>
    <script type="text/javascript">
function valForm()
{
    var x = document.forms["ActorForm"]["actorfname"].value;
   
    if (x == null || x == "")
    {
        alert("First name must be filled out");
        return false;
       
    }
   
}
</script>
</body>
    
</html>
0

Be sure to return true; when execution drops through the validation trap(s) otherwise the returned value is falsy and the form will not sumbit.

Edited by Airshow: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.