Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
im using this form validation on my site:
http://jorenrapini.com/blog/javascript/the-simple-quick-and-small-jquery-html-form-validation-solution[^]

the problem is that it doesnt mention the code for a select box.

can anyone give me the code for validating a select box?
my select box name and id is "country"
and if the selection stays on "country" i want an error notice
Posted
Updated 1-Apr-13 21:14pm
v3
Comments
[no name] 1-Apr-13 18:11pm    
Why are you not asking Joren about his code?
jfiler20 1-Apr-13 18:16pm    
because he has been asked that on his site about a month ago but never replied!

1 solution

Please follow below links:


jQuery-Form-Validation-with-Selects

validate-select-via-jquery

Validation

jquery-validation-for-drop-down-box



Don't forget to mark useful responses as Answer if they helped you towards a solution.
 
Share this answer
 
Comments
jfiler20 2-Apr-13 10:46am    
ok thanks...just one more thing
now that I got the code for the select box validation, i want the error text to fade in.

this is my code now:
<script type="text/javascript">
$(document).ready(function(){
$("#submit").click(function(){
var year = $('#year option:selected').val();
if(year == "")
$("#msg").fadeIn("slow");
{
$("#msg").html("Please select a year");
return false;

}
});
});
</script>

i tried adding this line under if(year == "") :
$("#msg").fadeIn("slow");

but it doesnt fade...
any ideas how to make the error alert fade?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900