Link to home
Start Free TrialLog in
Avatar of dcass
dcassFlag for United States of America

asked on

Javascript validation error

Could someone take a look at this and tell me where the error is?


<html>
<head>
<script type="text/javascript">
function Valdt() {
  var ErrMsg = "";
  var sTo = document.forms[0].iTo.value;
  var sFrom = document.forms[0].iFrom.value;
  var iDiff=0;
  if (sTo == "") {
    ErrMsg = "Please enter To record number. \n";
  }
  if (sFrom == "") {
    ErrMsg = "Please enter From record number. \n";
  }
// I know it's good up to here, but I just don't see any error past this.
  if (Errmsg == "") {
     var iTo =  parseInt(sTo,10);
     var iFrom = parseInt(sFrom,10);
     iDiff = (iTo-iFrom);
     if (iDiff > 301)  {
        ErrMsg = "Please enter 300 or less records to process. \n";
     }
  }
  if (ErrMsg == "") {
    document.forms[0].action='email1.asp';
    document.forms[0].submit();
   }
   else  {
    document.forms[0].action='email.asp';
    document.forms[0].submit();
  }
}
</script>
</head>
<body>
<form method=post>
From Record:
     <input name="iFrom" size="9" value="0">
<BR>
 To record:
     <input type="text" name="iTo" size="9" value="300">
 <INPUT TYPE="submit" border=1  VALUE="Submit" onClick="Valdt()">
</form>
</body>
</html>
ASKER CERTIFIED SOLUTION
Avatar of Sudhindra A N
Sudhindra A N
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of Amick
Amick
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Although there was no answer when I started my response, ansudhindra was quicker with a reply and should be rewarded appropriately.
Java-Script is case sensitive language.

You have written wrong variable name:

if (Errmsg == "") {

This should be:

if (ErrMsg == "") {
Avatar of dcass

ASKER

I was just too tired to see it!
Thanks for your quick response.