dimanche 19 avril 2015

I am trying to echo an alert when input field was empty, but it alway echo alert, jquery, wordpress?


Vote count:

0




I am using wordpress login. I am trying to call a function when the login or password input was empty. I am trying the following code, no matter I enter something into the input or nothing, it alway echo alert, why? I know inside input, value="", means nothing before I enter anything, even if I enter something, on the console, I still see the value="", I am confuse now. help, appreciate.





var user_login=$('#user_login').val();
var user_pwd=$('#user_pass').val();
$('#wp-submit').click(function(){
if (user_login=='' || user_pwd==''){
alert('hello');
}
});




<script src="http://ift.tt/1oMJErh"></script>
<input id="user_login" type="text" value="" name="log"></input>
<input id="user_pass" type="text" value="" name="pwd"></input>
<input id="wp-submit" type="submit" value="log in"></input>




asked 26 secs ago

conan

230






I am trying to echo an alert when input field was empty, but it alway echo alert, jquery, wordpress?

Aucun commentaire:

Enregistrer un commentaire