ron4721
asked on
how to validate <select> using jQuery form validation
Hi,
I'm using the jQuery validation (http://docs.jquery.com/Plugins/Validation) for my form. It works great for <input> fields and <textarea> fields. However, it doesn't show an error message for my two <select> dropdowns. I've read alot of discussion about this but with little solutions or answers.
Does anyone have a good rule or solution to use for forms with <select> dropdowns?
I've attached my code.
In my code, the part that I'm asking for help with a rule, relates to this code:
The jQuery validation rule:
<script type="text/javascript" charset="utf-8">
$(document).ready(function (){
$("#apForm").validate({
rules: {
}});
});
</script>
Thanks!
form-page.html
I'm using the jQuery validation (http://docs.jquery.com/Plugins/Validation) for my form. It works great for <input> fields and <textarea> fields. However, it doesn't show an error message for my two <select> dropdowns. I've read alot of discussion about this but with little solutions or answers.
Does anyone have a good rule or solution to use for forms with <select> dropdowns?
I've attached my code.
In my code, the part that I'm asking for help with a rule, relates to this code:
The jQuery validation rule:
<script type="text/javascript" charset="utf-8">
$(document).ready(function
$("#apForm").validate({
rules: {
}});
});
</script>
Thanks!
form-page.html
ASKER
I need to validate that the user has chosen one of the items on the select. For example, on my state/province/territory select, the user needs to pick one in the list. The same goes for the country select. How would you recommend I fix the HTML to have a default pre-selected?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
By default otherwise the first option is always selected.
What you can do once you choose a default is to check to see which value is selected and if the value is still the default then you should know that nothing has been changed and validate it that way.
What you can do once you choose a default is to check to see which value is selected and if the value is still the default then you should know that nothing has been changed and validate it that way.
ASKER
Thanks! It was something very simple that i overlooked. I appreciate your help!
Cd&