Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Javascript CheckForm not working
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Topic ClosedJavascript CheckForm not working

 Post Reply Post Reply
Author
fernan82 View Drop Down
Mod Builder Group
Mod Builder Group
Avatar

Joined: 17 November 2002
Location: United States
Status: Offline
Points: 362
Direct Link To This Post Topic: Javascript CheckForm not working
    Posted: 12 March 2003 at 7:17pm

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 += "\n\tYou must enter a subject.";
 }

 //Check for a Message Body
 if (document.frmPMs.pmBody.value==""){
  errorMsg += "\n\tYou must enter a message body.";
 }


 //If there is aproblem with the form then display an error
 if (errorMsg != ""){
  msg = "_______________________________________________________________\n\n";
  msg += "The form has not been submitted because there are problem(s) with the form.\n";
  msg += "Please correct the problem(s) and re-submit the form.\n";
  msg += "_______________________________________________________________\n\n";
  msg += "The following field(s) need to be corrected: -\n";

  errorMsg += alert(msg + errorMsg + "\n\n");
  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()">
<br>
<center><b>PM Group Mod by Fernan</b></center>
<br><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><br><br>
Subject: <input type="text" name="pmSubject" size="30" maxlength="41"><br>
<br>
<textarea rows="13" name="pmbody" cols="54"></textarea><br><br>
<center><input type="Submit" value="Send" name="Submit">&nbsp;&nbsp;<input type="reset" value="Reset" name="Reset"></center>
      </form>
      </p>
            </td>
    </tr>
  </table>


<br />
<div align="center">

</div>

FeRnAN
Back to Top
MadDog View Drop Down
Mod Builder Group
Mod Builder Group
Avatar

Joined: 01 January 2002
Status: Offline
Points: 3008
Direct Link To This Post Posted: 12 March 2003 at 7:28pm
the problem is your checking for a subject when there isnt a subject field in the form itself.
Back to Top
fernan82 View Drop Down
Mod Builder Group
Mod Builder Group
Avatar

Joined: 17 November 2002
Location: United States
Status: Offline
Points: 362
Direct Link To This Post Posted: 12 March 2003 at 7:30pm

There is a subject field...

Subject: <input type="text" name="pmSubject" size="30" maxlength="41"><br>

FeRnAN
Back to Top
MKrivanek View Drop Down
Groupie
Groupie


Joined: 05 March 2003
Location: United States
Status: Offline
Points: 84
Direct Link To This Post Posted: 13 March 2003 at 1:08am

Try onSubmit="return CheckForm();"

(adding the semicolon)? i wouldn't think the browser would be that anal... but it's worth a try

Back to Top
fernan82 View Drop Down
Mod Builder Group
Mod Builder Group
Avatar

Joined: 17 November 2002
Location: United States
Status: Offline
Points: 362
Direct Link To This Post Posted: 13 March 2003 at 9:42am
Thanks but it didn't work neither....that's confusing as i use the same code with different forms and it works with some but it don't with some others...
FeRnAN
Back to Top
ultramods View Drop Down
Groupie
Groupie
Avatar

Joined: 08 January 2003
Location: Scotland
Status: Offline
Points: 146
Direct Link To This Post Posted: 16 March 2003 at 3:53am

 Your problem is that you have used a lower case b and an upper case B for pmBody.

//Check for a Message Body
 if (document.frmPMs.pmBody.value ==""){
  errorMsg += "\n\tYou must enter a message body.";
 }

<textarea rows="13" name="pmbody"cols="54"></textarea><br><br>

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.