V
V
VPVPVP2021-06-21 11:18:56
JavaScript
VPVPVP, 2021-06-21 11:18:56

jquery validation doesn't work submit disable when fields are not valid?

There is a SUBMIT button, it looks like this

<p class="submit">
                          <input type="submit" name="wp-submit"
                               class="submit button button-primary button-large"
                               value="<?php echo esc_attr_x( 'Sign up', 'Login popup form', 'eduma' ); ?>"/>
                        </p>


There is such a validation script
jQuery(document).ready(function(){
           jQuery("form.auto_login").validate({

             rules:{
                user_login:{
                  required: true,
                  minlength: 4,
                  maxlength: 16,
                },
                password:{
                  required: true,
                  minlength: 6,
                  maxlength: 16,
                },


             },
             messages:{
               user_login:{
                 required: "Это поле обязательно для заполнения",
                 minlength: "Логин должен быть минимум 4 символа",
                 maxlength: "Максимальное число символов - 16",
             },
             
               password:{
               required: "Это поле обязательно для заполнения",
               minlength: "Пароль должен быть минимум 6 символа",
               maxlength: "Пароль должен быть максимум 16 символов",
               },
               submitHandler: function(form) { // <- pass 'form' argument in
            $(".submit").attr("disabled", true);
            form.submit(); // <- use 'form' argument here.
        }
              
    }
                 
          });

});


According to the idea, this piece should check the form and disable the button if the fields are not validly filled, but it doesn’t work, maybe I didn’t stick the button class correctly at all? Although I already tried everything in a row.

submitHandler: function(form) { // <- pass 'form' argument in
            $(".submit").attr("disabled", true);
            form.submit(); // <- use 'form' argument here.
        }

Answer the question

In order to leave comments, you need to log in

5 answer(s)
V
Vovash, 2021-06-21
@V0vash

submitHandler: function(form) { // <- pass 'form' argument in
            $(".submit").attr("disabled", true);
            form.submit(); // <- use 'form' argument here.
        }

here, first you need to process the result of form validation, then, depending on the result, either block or send,
now it happens like this: in any case, we block and in any case we send

R
Radriga, 2012-10-02
@Radriga

I may seem Q.O., but the grep utility is missing
if you are using the ipkg package manager, then do ipkg install grep

I
iandriyanov, 2012-10-02
@iandriyanov

Something with firefox.

A
Alexey Akulovich, 2012-10-02
@AterCattus

I have WL-500GP v2 with firmware from here . Grep in the system is:
# /bin/grep
BusyBox v1.19.3 (2012-06-12 19:25:23 MSK) multi-call binary.

See what you have there.
PS As ipkg is ipkg.sh

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question