I find it very weird to see that if i display an error on error div on form submit they just disappear straight away
my test code
<!DOCTYPE html>
<html>
<head>
<title>TEST</title>
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
</head>
<body>
<form method="post" id="fid" action="#">
<input type="text"><div id="err"></div>
<input type="submit" value="Submit" name="button" />
</form>
<script type="text/javascript">
$(function(){
$('#fid').submit(function(){
$('#err').text('Hello World');
//$('#err').html('Hello World');
});
});
</script>
</body>
</html>
I'm just displaying an error message regardless if user has left the field empty or not just to check once i get this successfully then i would go and implement the full functionality.
PLEASE NOTE: the error mess appear for less then a second and then disappear automaticlly
Regards
e.preventDefault(); stop the form submit action
$(function(){
$('#fid').click(function(e){
e.preventDefault();
$('#err').text('Hello World');
//$('#err').html('Hello World');
});
});
If this method is called, the default action of the event will not be triggered
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With