Jquery form submit to check empty fields -


how use jquery check if text-fields empty when submit without loading login.php?

<form action="login.php" method="post">     <label>login name:</label>     <input type="text" name="email" id="log" />     <label>password:</label>     <input type="password" name="password" id="pwd" />     <input type="submit" name="submit" value="login" /> </form> 

thanks.

you can this:

//  bind event handler "submit" javascript event $('form').submit(function () {      // login name value , trim     var name = $.trim($('#log').val());      // check if empty of not     if (name  === '') {         alert('text-field empty.');         return false;     } }); 

fiddle demo


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -