check multiple ifield if it's blank in jquery 1

check multiple ifield if it’s blank in jquery

$('#Rusername, #Remail, #Rpassword, #Rpassword2').each(function() {
  if ($(this).val() == '') {
    $(this).parent().effect('shake', {times: 3}, 50).find('.verdiv').addClass('error');
  }
});

Here is what the above code is Doing:
1. It’s checking if the username, email, password, and password2 fields are empty.
2. If they are empty, it’s shaking the parent div of the field and adding the class ‘error’ to the div with the class ‘verdiv’.
3. If they are not empty, it’s removing the class ‘error’ from the div with the class ‘verdiv’.

Now, let’s add the following code to the bottom of the file:

Similar Posts