vendredi 15 juillet 2016

Didn't updating class for element - jQuery [duplicate]

This question already has an answer here:

After blur, if input is empty, i want to add class .hass-error, after that i write some text into input, on idea class .hass-error must removed and added class has-success. .has-error is removing but new clas

function checkSignupData() {
      var username = $('.signup-panel input[name="username"]');

        username.on({
          'focusin': function(){},
          'focusout': function(){
            if(!this.value.length) {
              $(this).closest('.form-group').removeClass('has-success').toggleClass('has-error');
            }
            else if(this.value.length > 3 && this.value.length < 32) {
              $(this).closest('.form-group').removeClass('has-error').toggleClass('has-success');
            }
          }
        });
    }
    setInterval(checkSignupData(), 100);

Aucun commentaire:

Enregistrer un commentaire