I want to validate user input when the user clicked on the submit button, but it won't work.
jQuery
$(document).ready(function() {
function validateForm() {
if ($('#u').value() == '')
{
alert("no value found");
return false;
}
});
});
HTML
<form name="myForm" action="main.php" onsubmit="return validateForm()" method="post">
<input type="text" id="u" />
<input type="submit" value="submit" />
</form>
id="u"in your form.$('#u').val(). And you'll get it