Вопрос

Does anyone know why this validation is not working, I am trying to enforce alphanumeric input of 8-12 chars but nothing is happening, I have linked to the external jquery form validation library as you can see:

<form id="userTest">    
  <table>
   <tr>
    <td>Password</td><td><input type="password" id="pwd"></input></td>
   </tr>
 </table>
</form>

The Jquery:

$(function(){
    $("form#userTest").validate({
         rules:{
              pwd:{
                   alphanumeric: true,
                   minlength: 8,
                   maxlength: 12      
              }
         }
    });
});

http://jsfiddle.net/zCjav/

Это было полезно?

Решение

you are missing the additional-methods.js file where the alpha-numeric rule is added, also you might want to add the required validation

jQuery(function ($) {
    $("form#userTest").validate({
        rules:{
            pwd:{
                required: true,
                alphanumeric: true,
                minlength: 8,
                maxlength: 12     
            }
        }
    });
});

Demo: Fiddle

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top