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; } });
Comments
Post a Comment