Jquery Validate



  • There's a form of authorization, and there's a crypt that checks the evalence of the e-mail, the password (dlina). So, how do you redesign the crypt to check the mail and password and check the symbols? Here's the violin.

            <script type="text/javascript">
            $(function()
            {
                // Validation
                $("#sky-form").validate(
                {                   
                    // Rules for form validation
                    rules:
                    {
                        email:
                        {
                            required: true,
                            email: true
                        },
                        password:
                        {
                            required: true,
                            minlength: 3,
                            maxlength: 20
                        }
                    },
    
                // Messages for form validation
                messages:
                {
                    email:
                    {
                        required: 'Вы не ввели адрес эл.почты',
                        email: 'Вы не правильно ввели адрес эл.почты'
                    },
                    password:
                    {
                        required: 'Вы не ввели пароль'
                    }
                },                  
    
                // Do not change code below
                errorPlacement: function(error, element)
                {
                    error.insertAfter(element.parent());
                }
            });
        });         
    &lt;/script&gt;
    



  • Use regex.

    function validateEmail(email) {
        var re = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
        return re.test(email);
    }
    



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2