Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clear password text field in Jquery

Tags:

jquery

I want to clear the password text field each time the pop-up is shown. The pop-up contains the password field

I'm using below function in jquery to reset:

function resetPopupFormErrors() {
    $("div.errors").closest("tr").remove();
     ....
}

And I'm calling this function in fancybox on startup. How can I reset the password text in above function so that if the user has typed something in text field & closed the pop-up & then if user opens it again, I don't want that password to reappear....How can I do it using jquery in above function?

EDIT: If I look at the html view source after typing the password, the value is empty for that password field. How can we clear something that's not appearing in value field? Thanks!

like image 278
Mike Avatar asked Nov 29 '22 03:11

Mike


2 Answers

Why not just set the textbox's value to ''?

$('input[type="password"]').val('');

Note that this resets all password textboxes. Use an id if you want to target a specific one.

like image 106
Blender Avatar answered Dec 12 '22 11:12

Blender


Wouldnt you do it the same as clearing a normal text box?

$("#yourTextBox").val('');
like image 35
Mungoid Avatar answered Dec 12 '22 10:12

Mungoid