Javascript

 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me



Go Back   Tutorialized ForumsWeb Design & DevelopmentJavascript

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Tutorialized Forums Sponsor:
  #1  
Old July 11th, 2012, 02:00 PM
nkaldenberg nkaldenberg is offline
Registered User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Jul 2012
Posts: 3 nkaldenberg User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 19 m 38 sec
Reputation Power: 0
Validation stopped working

I posted this in the frontpage forum since I am using frontpage but I believe my problem is with my javascript so I'll ask here as well.

I built a registration form with validation using javascript everything was working 2 days ago when I made it but when I came back to work today it wasn't doing any form of validation and would send the form every time.

If someone could take a look at it and give me an idea of where it went bad it would be much appreciated.

Code:
<html>
 
<head>
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>New Page 1</title>
</head>
 
<body>
 
<script Language="JavaScript" Type="text/javascript"><!--
function validationcheck(theForm)
{
 
  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwx  yz   \t\r\n\f";
  var checkStr = theForm.First_Name.value;
  var allValid = true;
  var validGroups = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter only letter and whitespace characters in the First Name field.");
    theForm.First_Name.focus();
    return (false);
  }
 
  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwx  yz   \t\r\n\f";
  var checkStr = theForm.Last_Name.value;
  var allValid = true;
  var validGroups = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter only letter and whitespace characters in the Last Name field.");
    theForm.Last_Name.focus();
    return (false);
  }
 
  var chkVal = theForm.Email_Confirm.value;
  var prsVal = chkVal;
  var mail1 = theForm.Email.value;
  if (chkVal != "" && !(prsVal == mail1))
  {
    alert("Email Addresses do not match.");
    theForm.Email_Confirm.focus();
    return (false);
  }
 
  if (theForm.PW.value == "")
  {
    alert("Please enter a value for the Password field.");
    theForm.PW.focus();
    return (false);
  }
 
  if (theForm.PW.value.length < 4)
  {
    alert("Please enter at least 4 characters in the Password field.");
    theForm.PW.focus();
    return (false);
  }
 
  if (theForm.PW.value.length > 13)
  {
    alert("Please enter at most 13 characters in the Password field.");
    theForm.PW.focus();
    return (false);
  }
 
  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwx  yz  0123456789-";
  var checkStr = theForm.PW.value;
  var allValid = true;
  var validGroups = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter only letter and digit characters in the Password field.");
    theForm.PW.focus();
    return (false);
  }
  var chkVal = theForm.pw_confirm.value;
  var prsVal = chkVal;
  var pwchk = theForm.PW.value;
  if (chkVal != "" && !(prsVal == pwchk))
  {
    alert("Passwords do not match.");
    theForm.pw_confirm.focus();
    return (false);
  }
  var checkOK = "0123456789-";
  var checkStr = theForm.Verification.value;
  var allValid = true;
  var validGroups = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter only digit characters in the Verification field.");
    theForm.Verification.focus();
    return (false);
  }
 
  var chkVal = theForm.Verification.value;
  var prsVal = chkVal;
  if (chkVal != "" && !(prsVal == "18"))
  {
    alert("Please enter the sum of eleven and seven into the Verification field.");
    theForm.Verification.focus();
    return (false);
  }
  return (true);
  {
   var spam - theForm.Password.value;
   if (spam !="")
   {
     alert("If you are human do not fill in this field.");
     return (false);
     }
     return (true);
     }
}
//--></script><!--webbot BOT="GeneratedScript" endspan -->&nbsp;<form method="POST" action="--WEBBOT-SELF--" onsubmit="return validationcheck(this)" language="JavaScript" name="sign_up_form">
  <!--webbot bot="SaveResults" u-file="_private/validation-results.htm" s-format="HTML/BR" s-label-fields="TRUE" b-reverse-chronology="FALSE" s-date-format="%Y-%m-%d" s-time-format="%I:%M %p %Z" s-builtin-fields="REMOTE_NAME REMOTE_USER HTTP_USER_AGENT Date Time" s-form-fields="First_Name Last_Name Email Company Username Password Security_Question Security_Answer " startspan --><input TYPE="hidden" NAME="VTI-GROUP" VALUE="0"><!--webbot bot="SaveResults" endspan i-checksum="43374" --><p>&nbsp;</p>
  <div align="center">
    <center>
  <table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111">
    <tr>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td>
      <p align="right"><span lang="en-us">First Name:</span></td>
      <td>
      <input type="text" name="First_Name" size="20" tabindex="1"></td>
    </tr>
    <tr>
      <td>
      <p align="right">&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td>
      <p align="right"><span lang="en-us">Last Name:</span></td>
      <td>
      <input type="text" name="Last_Name" size="20" tabindex="2"></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td>
      <p align="right"><span lang="en-us">Email:</span></td>
      <td><input type="text" name="Email" size="20" tabindex="3"></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td>
      <p align="right"><span lang="en-us">Confirm Email:</span></td>
      <td>
      <input type="text" name="Email_Confirm" size="20" tabindex="4"></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td>
      <p align="right"><span lang="en-us">Company:</span></td>
      <td><input type="text" name="Company" size="20" tabindex="5"></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td>
      <p align="right"><span lang="en-us">Username:</span></td>
      <td><input type="text" name="Username" size="20" tabindex="6"></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td>
      <p align="right"><span lang="en-us">Password:</span></td>
      <td>
      <input type="password" name="PW" size="20" maxlength="13" tabindex="7"></td>
    </tr>
    <tr>
      <td>
      <p align="right"><span lang="en-us"><font size="1">(password is case 
      sensitive and must be between 4 and 13 letters and/or numbers.)</font></span></td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td>
      <p align="right"><span lang="en-us">Confirm Password:</span></td>
      <td>
      <input type="password" name="pw_confirm" size="20" maxlength="13" tabindex="8"></td>
    </tr>
    <tr>
      <td>
      <p align="right">&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td>
      <p align="right"><span lang="en-us">Security Question:</span></td>
      <td>
      <input type="text" name="Security_Question" size="20" tabindex="9"></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td>
      <p align="right"><span lang="en-us">Security Answer:</span></td>
      <td>
      <input type="text" name="Security_Answer" size="20" tabindex="10"></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td>
      <p align="right"><span lang="en-us">Verification:</span></td>
      <td><span lang="en-us">&nbsp;What is the sum of seven and 
      eleven?</span></td>
    </tr>
    <tr>
      <td>
      <p align="right"><span lang="en-us"><font size="1">(answer in number 
      form.)</font></span></td>
      <td>
      <input type="text" name="Verification" size="20" tabindex="11"></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
  </table>
    </center>
  </div>
  <p align="center">
  &nbsp;</p>
  <div id="antispam" style="display: none"> <input type="text" name="Password" size="20"></div> 
  <p align="center">
  <input type="submit" value="Submit" name="submit" tabindex="11"><input type="reset" value="Reset" name="reset" tabindex="12"></p>
</form>
 
</body>
 
</html>

Reply With Quote
  #2  
Old July 11th, 2012, 02:26 PM
nkaldenberg nkaldenberg is offline
Registered User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Jul 2012
Posts: 3 nkaldenberg User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 19 m 38 sec
Reputation Power: 0
I tried a few different things and found out my error is with this piece of code:

Code:
var spam - theForm.Password.value;
   if (spam !="")
   {
     alert("If you are human do not fill in this field.");
     return (false);
     }
     return (true);


it is supposed to check to see if the hidden field (Password) has anything entered into it and to not pass the validation if there is.

anyone know how I can fix this?
Comments on this post
dishagandhi agrees!

Reply With Quote
  #3  
Old July 11th, 2012, 02:46 PM
nkaldenberg nkaldenberg is offline
Registered User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Jul 2012
Posts: 3 nkaldenberg User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 19 m 38 sec
Reputation Power: 0
wow nevermind i can't believe it took me that long to see that i had "-" instead of "="

Reply With Quote
  #4  
Old July 11th, 2012, 09:13 PM
jamespayne's Avatar
jamespayne jamespayne is offline
Editor-in-Beef
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Sep 2008
Location: South Florida
Posts: 31 jamespayne User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 9 h 48 m 44 sec
Reputation Power: 10
Glad you figured it out and thanks for posting the solution - appreciate it!

Reply With Quote
Reply

Viewing: Tutorialized ForumsWeb Design & DevelopmentJavascript > Validation stopped working


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap