I'm making a form and when I hit submit it will submit the form even if I leave everything blank...............what am i doing wrong??
here's the code:
<html>
<head>
<script language="JavaScript">
<!-- Hide from older browsers...
//Function to check form is filled in correctly before submitting
function CheckForm () {
var errorMsg = "";
//Check for a Subject
if (document.frmPMs.pmSubject.value==""){
errorMsg += "
You must enter a subject.";
}
//Check for a Message Body
if (document.frmPMs.pmBody.value==""){
errorMsg += "
You must enter a message body.";
}
//If there is aproblem with the form then display an error
if (errorMsg != ""){
msg = "_______________________________________________________________
";
msg += "The form has not been submitted because there are problem(s) with the form.
";
msg += "Please correct the problem(s) and re-submit the form.
";
msg += "_______________________________________________________________
";
msg += "The following field(s) need to be corrected: -
";
errorMsg += alert(msg + errorMsg + "
");
return false;
}
return true;
}
// -->
</script>
</head>
<title>PM Groups Mod by Fernan</title>
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="50%" id="AutoNumber1" height="95" align = "center">
<tr>
<td width="100%" height="95" valign="top">
<form method="post" name="frmPMs" action="send_pms.asp" onSubmit="return CheckForm()">
<center>PM Group Mod by Fernan</center>
<p style="margin-left: 10; margin-right: 10">
Group to PM:
<select size="1" name="pmGID">
<option value="1">Forum Ådministrator</option>"
<option value="3">Forum Moderator</option>"
<option value="4">Newbie</option>"
<option value="5">Full Member</option>"
<option value="6">Advanced Member</option>"
<option value="7">Underground Member</option>"
</select>
Subject: <input type="text" name="pmSubject" size="30" maxlength="41">
<textarea rows="13" name="pmbody" cols="54"></textarea>
<center><input type="Submit" value="Send" name="Submit"> <input type="reset" value="Reset" name="Reset"></center>
</form>
</p>
</td>
</tr>
</table>
<div align="center">
</div>
</html>
Archived topic from Iceteks, old topic ID:359, old post ID:1769
Javascript Checkform Not Working.....:(
Javascript Checkform Not Working.....:(
Oh well here's the code:
I didn't knew you had to do that to post the code...
Archived topic from Iceteks, old topic ID:359, old post ID:1770
Code: Select all
I'm making a form and when I hit submit it will submit the form even if I leave everything blank...............what am i doing wrong??
here's the code:
<html>
<head>
<script language="JavaScript">
<!-- Hide from older browsers...
//Function to check form is filled in correctly before submitting
function CheckForm () {
var errorMsg = "";
//Check for a Subject
if (document.frmPMs.pmSubject.value==""){
errorMsg += "
You must enter a subject.";
}
//Check for a Message Body
if (document.frmPMs.pmBody.value==""){
errorMsg += "
You must enter a message body.";
}
//If there is aproblem with the form then display an error
if (errorMsg != ""){
msg = "_______________________________________________________________
";
msg += "The form has not been submitted because there are problem(s) with the form.
";
msg += "Please correct the problem(s) and re-submit the form.
";
msg += "_______________________________________________________________
";
msg += "The following field(s) need to be corrected: -
";
errorMsg += alert(msg + errorMsg + "
");
return false;
}
return true;
}
// -->
</script>
</head>
<title>PM Groups Mod by Fernan</title>
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="50%" id="AutoNumber1" height="95" align = "center">
<tr>
<td width="100%" height="95" valign="top">
<form method="post" name="frmPMs" action="send_pms.asp" onSubmit="return CheckForm()">
<center><b>PM Group Mod by Fernan</b></center>
<p style="margin-left: 10; margin-right: 10">
Group to PM:
<select size="1" name="pmGID">
<option value="1">Forum Ådministrator</option>"
<option value="3">Forum Moderator</option>"
<option value="4">Newbie</option>"
<option value="5">Full Member</option>"
<option value="6">Advanced Member</option>"
<option value="7">Underground Member</option>"
</select>
Subject: <input type="text" name="pmSubject" size="30" maxlength="41">
<textarea rows="13" name="pmbody" cols="54"></textarea>
<center><input type="Submit" value="Send" name="Submit"> <input type="reset" value="Reset" name="Reset"></center>
</form>
</p>
</td>
</tr>
</table>
<div align="center">
</div>
</html>
Archived topic from Iceteks, old topic ID:359, old post ID:1770
- Red Squirrel
- Posts: 29209
- Joined: Wed Dec 18, 2002 12:14 am
- Location: Northern Ontario
- Contact:
Javascript Checkform Not Working.....:(
Yeah this board supports html, it can come handy, but I always keep an eye out for trouble makers.
As for your code, I'm not sure, I don't really know javascript.
Oh, I moved this to the coding forum.
Archived topic from Iceteks, old topic ID:359, old post ID:1771
As for your code, I'm not sure, I don't really know javascript.
Oh, I moved this to the coding forum.
Archived topic from Iceteks, old topic ID:359, old post ID:1771
Honk if you love Jesus, text if you want to meet Him!
Javascript Checkform Not Working.....:(
Looks like it fixed itself
Archived topic from Iceteks, old topic ID:359, old post ID:1774
Archived topic from Iceteks, old topic ID:359, old post ID:1774
- rovingcowboy
- Posts: 1504
- Joined: Wed Dec 18, 2002 10:14 pm
Javascript Checkform Not Working.....:(
not sure what the trouble was? it will submit empty form if that is what you want. do you not want it to submit empty form? if so then you need to add line for it to insist there is something in the comment area before it is sent.
you know you seen the forms online that require certin information.
same thing is needing to be done here.
cant remember the code but will look for it and let you know.
mean time you can look for it at javascripts.com i believe that is it.
you can also get the first page 2000 program and use its feature of checking the page before it previews it. then it will say what and where the error is. or if there is any.
it also has the must have filled code in its code sections.
oops i just seen your code has it in there? so am not sure why it did that.?
Archived topic from Iceteks, old topic ID:359, old post ID:1780
you know you seen the forms online that require certin information.
same thing is needing to be done here.
cant remember the code but will look for it and let you know.
mean time you can look for it at javascripts.com i believe that is it.
you can also get the first page 2000 program and use its feature of checking the page before it previews it. then it will say what and where the error is. or if there is any.
it also has the must have filled code in its code sections.
oops i just seen your code has it in there? so am not sure why it did that.?
Archived topic from Iceteks, old topic ID:359, old post ID:1780
roving cowboy/ keith
Javascript Checkform Not Working.....:(
Its fixed, i'm not sure why it was doing that, i changed a line of ASP code and then changed it back to what it originally was and next time i ran the script it was working fine so i still have no idea what the prob. was........but now it's working fine....
Archived topic from Iceteks, old topic ID:359, old post ID:1781
Archived topic from Iceteks, old topic ID:359, old post ID:1781
Javascript Checkform Not Working.....:(
m$ tech.fernan82 wrote: Its fixed, i'm not sure why it was doing that, i changed a line of ASP code and then changed it back to what it originally was and next time i ran the script it was working fine so i still have no idea what the prob. was........but now it's working fine....
i would occassionally have that same problem with vc++. don't know why it happens, but it does.
Archived topic from Iceteks, old topic ID:359, old post ID:1785
Resistance is futile...
Registered Linux User #321628
Anime/Toon Avatars
Other Cool Forums
"Never hold your farts in. They travel up your spine, into your brain, and that's where you get s**tty ideas from..." - Woyaya - January 10, 2004
- Red Squirrel
- Posts: 29209
- Joined: Wed Dec 18, 2002 12:14 am
- Location: Northern Ontario
- Contact:
Javascript Checkform Not Working.....:(
Yep,
MS != consistant
Archived topic from Iceteks, old topic ID:359, old post ID:1793
MS != consistant
Archived topic from Iceteks, old topic ID:359, old post ID:1793
Honk if you love Jesus, text if you want to meet Him!