Do not use on any
shared computer
August 29, 2008 08:02pm pdt
 
[x]
Attachment Details

Validate 2 fields. Working in IE, but not in Firefox

Tags: fields, validate, 2, firefox
I have a page that has two fields(drop-downs) which are "Length of Service in years:"and the second field "Job Type:" with a  "submit" button right after.

In IE, if the fields are left blank, and  the SUBMIT button is clicked, then I get the two pop up boxes that remind user to fill in those fields before submitting the page. So it works in IE.

In Firefox, however, if I click the "Submit" button, then I only get one pop up box to remind user to enter the first field, but I do not get the second pop up for the second field. Also, when user clicks "OK" on the pop-up box for the first one, it automatically acts as though the Submit button is clicked and moves on to the next page.

Here's the code I am working with:

<SCRIPT>
function validate() {
if (main.los.options[0].selected) {
  alert('Please choose Length of Service in years.');
  event.returnValue=false;
}
if (main.job_desc.options[0].selected) {
  alert('Please choose Job Type.');
  event.returnValue=false;

}
}
</SCRIPT>

Here's the option value list for both fields:

 <td align="center">Length of Service in years:&nbsp;&nbsp;
              <select name="los" id="los">
                <option value ="0">Select</option>
                <option value="Less Than 6 Months">Less Than 6 Months</option>
                <option value="6-12 Months">6-12 Months</option>
                <option value="1-3 Years">1-3 Years</option>
                <option value="3-5 Years">3-5 Years</option>
                <option value="More Than 5 Years">More Than 5 Years</option>
              </select></td>

------

 <td align="center">Job Type:&nbsp;&nbsp;
              <select name="job_desc" id="job_desc">
                <option value ="0">Select</option>
                <option value="Administrator">Administrator</option>
                <option value="Director">Director</option>
                <option value="Physician">Physician</option>
                <option value="Nurse Director">Nurse Director</option>
                <option value="Assistant Nurse Director">Assistant Nurse Director</option>
                <option value="RN">RN</option>
              </select></td>

And lastly here's what I have for the SUBMIT button:

 <input name="" type="submit" onsubmit="validate()">

So how do I fix this?
Start your free trial to view this solution
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

Question Stats
Zone: Programming
Question Asked By: super786
Solution Provided By: Zvonko
Participating Experts: 1
Solution Grade: A
Views: 0
Translate:
Loading Advertisement...
 
[+][-]Expert Comment by Zvonko

Rank: Genius

Expert Comment by Zvonko:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Author Comment by super786
Author Comment by super786:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Accepted Solution by Zvonko

Rank: Genius

Accepted Solution by Zvonko:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
20080723-EE-VQP-34 / EE_QW_2_20070628