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>
Member Avatar for stbuchok

I'll give you a hint valForm !== valFrom

;)

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>

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.