mdconnor
01-05-2007, 06:14 AM
Hi,
New to JavaScript is an understatement but here goes. Sorry about the "{}" thingies but I put them together so I could stay up with them. :D I would appreciate any help if someone would be so kind.
My goal is to compare e-mail addresses to make sure they are the same and to make sure the fields are not mt. I ended up with two script sections in the head for my best results. It works except after the "The e-mail fields aren't the same!!" alert is clicked it goes ahead and submits the form. This is making my head hurt after two days on it. Thanks
<html>
<head>
<script type="text/javascript">
function validate_required(field,alerttxt)
{with (field)
{if (value==null||value=="")
{alert(alerttxt);return false}
else {return true}}}
function validate_form(thisform)
{with (thisform)
{if (validate_required(mail,"Please fill out your name and e-mail address so I can contact
you")==false)
{mail.focus();return false}}}
</script>
<script type="text/javascript">
function check(a,b) {
var obja = document.getElementById(a)
var objb = document.getElementById(b)
if (obja.value==objb.value) {}
else {alert("The e-mail fields aren't the same!!");return false;}}
</script>
</head>
<body>
<form action="gdform.asp" onsubmit="return validate_form(this)"method="post">
<input type="hidden" name="subject" value="Form Submission" />
<input type="hidden" name="redirect" value="thankyouredriver.html" />
<h4>Use this form to send Mike feedback.</h4>
Your Name:<br>
<input type="text" name="name">
<br><BR><br>
Your E-Mail address:<br>
<input type="text" name="mail">
<br><br>
Confirm E-Mail address:<br>
<input type="text" name="mail2">
<br><br>
<input type="submit" onclick="check('mail','mail2')"name="submit" value="Submit"/>
<input type="reset" value="Reset">
</form>
</body>
</html>
New to JavaScript is an understatement but here goes. Sorry about the "{}" thingies but I put them together so I could stay up with them. :D I would appreciate any help if someone would be so kind.
My goal is to compare e-mail addresses to make sure they are the same and to make sure the fields are not mt. I ended up with two script sections in the head for my best results. It works except after the "The e-mail fields aren't the same!!" alert is clicked it goes ahead and submits the form. This is making my head hurt after two days on it. Thanks
<html>
<head>
<script type="text/javascript">
function validate_required(field,alerttxt)
{with (field)
{if (value==null||value=="")
{alert(alerttxt);return false}
else {return true}}}
function validate_form(thisform)
{with (thisform)
{if (validate_required(mail,"Please fill out your name and e-mail address so I can contact
you")==false)
{mail.focus();return false}}}
</script>
<script type="text/javascript">
function check(a,b) {
var obja = document.getElementById(a)
var objb = document.getElementById(b)
if (obja.value==objb.value) {}
else {alert("The e-mail fields aren't the same!!");return false;}}
</script>
</head>
<body>
<form action="gdform.asp" onsubmit="return validate_form(this)"method="post">
<input type="hidden" name="subject" value="Form Submission" />
<input type="hidden" name="redirect" value="thankyouredriver.html" />
<h4>Use this form to send Mike feedback.</h4>
Your Name:<br>
<input type="text" name="name">
<br><BR><br>
Your E-Mail address:<br>
<input type="text" name="mail">
<br><br>
Confirm E-Mail address:<br>
<input type="text" name="mail2">
<br><br>
<input type="submit" onclick="check('mail','mail2')"name="submit" value="Submit"/>
<input type="reset" value="Reset">
</form>
</body>
</html>