I'm trying to clear all the inputs that are password type when jquery validation fails - I tried the following (which doesn't work) :
$('input[type=password]').val('');
Any ideas?
We can clear an input field using jQuery easily by making use of the jQuery val() method. We simply need to set the value of the input field to an empty string.
Try with
$("input[type='password']").val('');
Try using the :password
selector as it will make your code shorter:
$(':password').val('');
Also your initial code should work. Your problem is somewhere else. Unfortunately as you haven't stated in what context and how this is called or as you haven't explained what it doesn't work mean I cannot help you further.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With