下拉验证

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了下拉验证相关的知识,希望对你有一定的参考价值。

requires that a pulldown \"program1\" in form \"freshmen\" be set to anything but the first value in the option list. \r\n\r\nrequires jquery validate: http://docs.jquery.com/Plugins/Validation
  1. jQuery.validator.addMethod(
  2. "selectNone",
  3. function(value, element) {
  4. //alert(element.options.selectedIndex);
  5. //if (element.value == "blank"){
  6. if (element.options.selectedIndex == "0"){
  7. return false;
  8. }
  9. else return true;
  10. },
  11. "Please select an option."
  12. );
  13.  
  14. $(document).ready(function(){
  15.  
  16.  
  17. $("#freshmen").validate({
  18. rules: {
  19. program1: {
  20. selectNone: true
  21. }
  22. }
  23.  
  24. });

以上是关于下拉验证的主要内容,如果未能解决你的问题,请参考以下文章