Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
97
rated 0 times [  104] [ 7]  / answers: 1 / hits: 20087  / 11 Years ago, thu, may 9, 2013, 12:00:00

I have searched a lot in stackoverflow and other sites and got many solutions but nothing solved mine.That is why I am posting this.I have a password field in my web page, which was created dynamically on a link click.And I want to get the value typed in that password field into a variable when it loses focus.For that i created a jQuery function like this.



$('#parentdiv').on('focusout', '#passwordfield', function() {
var pass1 = $('#passwordfield').val();
alert(pass1);
alert(Hello);
});


Here the first alert command will displayed with nothing, but the second alert come with Hello. Which means, when the password field loses its focus this function executes without any problem, but the problem is, it is not getting the password field value.



Please help me to solve this problem.



EDIT



This is my html



<input type=password size=20 id=passwordfield />

More From » jquery

 Answers
10

you can try this:



HTML code:



<form id='form'>
<input type='password' class='required' />
</form>


JavaScript:



$('#form .required').focusout(function(){
var txt = $(this).val();
$('.required').after(txt);
});


or you can check this code at http://jsfiddle.net/92y6b/


[#78343] Tuesday, May 7, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
gavenmekhio

Total Points: 732
Total Questions: 89
Total Answers: 93

Location: Central African Republic
Member since Mon, Aug 10, 2020
4 Years ago
;