Help-----combining 3 scripts to one

16 views
Skip to first unread message

woody

unread,
Dec 7, 2011, 4:21:29 PM12/7/11
to JavaScript Form Validation
Hello... not very good at javascript , I have been trying to hook
three of the same script in a row but only the last one validates
properly the first two are skipped over, so I have been trying to form
1 script out of the three, have had no success, so I thought I would
ask if anyone here would know, any help would be appreciated.
below is what I am working with :

<html>
<head>
<script type="text/javascript">
function validateForm()
{
var x=document.forms["new customer"]["b_name"].value;
if (x==null || x=="")
{
alert("First name must be filled out");
return false;
}

}
</script>
<script type="text/javascript">
function validateForm()
{
var x=document.forms["new customer"]["b_last"].value;
if (x==null || x=="")
{
alert("Last name must be filled out");
return false;
}
}
</script>
</script>
<script type="text/javascript">
function validateForm()
{
var x=document.forms["new customer"]["b_phone"].value;
if (x==null || x=="")
{
alert("phone must be filled out");
return false;
}
}
</script>
</head>

<body>
<form name="new customer" action="www.ccwa34.com" onsubmit="return
validateForm()" method="post">
First Name: <input type="text" name="b_name">

Last Name: <input type="text" name="b_last">

Phone: <input type="text" name="b_phone">

<input type="submit" value="Submit">

</form>
</body>

</html>

thanks

Reply all
Reply to author
Forward
0 new messages