Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: validation form
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 1-Apr-13 13:01pm
Edited 1-Apr-13 22:14pm
Maciej Los158.8K
v3
Comments
ThePhantomUpvoter at 1-Apr-13 18:11pm
   
Why are you not asking Joren about his code?
jfiler20 at 1-Apr-13 18:16pm
   
because he has been asked that on his site about a month ago but never replied!

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
Comments
jfiler20 at 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)

  Print Answers RSS
0 OriginalGriff 290
1 Jochen Arndt 165
2 DamithSL 125
3 PIEBALDconsult 110
4 Garth J Lancaster 90
0 OriginalGriff 5,790
1 DamithSL 4,601
2 Maciej Los 4,012
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,195


Advertise | Privacy | Mobile
Web01 | 2.8.141220.1 | Last Updated 2 Apr 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100