troubleshooting Question

Javascript Validation problem: Validate if one field is greater than another

Avatar of rtis1
rtis1 asked on
JavaScriptWeb DevelopmentScripting Languages
4 Comments1 Solution1054 ViewsLast Modified:
Hello all,

I know there is a simple answer to this, but I have been having problems validating of one field is graeter than another.
The form is pretty simple and in it I have two select fields: StartTime and EndTime as follows:

<select name="CallStart">
<option value="">---</option>
<option value=8>8AM</option>
<option value=9>9AM</option>
<option value=10>10AM</option>
<option value=11>11AM</option>
<option value=12>12PM</option>
<option value=13>1PM</option>
<option value=14>2PM</option>
<option value=15>3PM</option>
<option value=16>4PM</option>
<option value=17>5PM</option>
<option value=18>6PM</option>
<option value=19>7PM</option>
<option value=20>8PM</option>
<option value=21>9PM</option>
<option value=22>10PM</option>
</select>

<select name="CallEnd" >
<option value="">---</option>
<option value=8>8AM</option>
<option value=9>9AM</option>
<option value=10>10AM</option>
<option value=11>11AM</option>
<option value=12>12PM</option>
<option value=13>1PM</option>
<option value=14>2PM</option>
<option value=15>3PM</option>
<option value=16>4PM</option>
<option value=17>5PM</option>
<option value=18>6PM</option>
<option value=19>7PM</option>
<option value=20>8PM</option>
<option value=21>9PM</option>
<option value=22>10PM</option>
</select>

I need to ensure that the CallStart time is not greater than the CallEnd time and I used the following Javascript validation:

    if (myform.tel1_callstart.value > myform.tel1_callend.value)
  {
    alert('Your preferred call start time cannot be later than your call end time".');
    myform.tel1_callstart.focus();
    return (false);
  }

However this does not seem to work and I'm not sure what i'm doing wrong.
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 4 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros