Hello,
I am trying to put a simple validation for the input text field. In the browser this is working something like this.
1st click - no message is displaying.
2nd click - message is displaying 2 times.
3rd click - message is displaying 3 times.
and so on.
Here is the code.
Please help me to resolve the issue.
Regards & Thanks.
I am trying to put a simple validation for the input text field. In the browser this is working something like this.
1st click - no message is displaying.
2nd click - message is displaying 2 times.
3rd click - message is displaying 3 times.
and so on.
Here is the code.
HTML Code:
<html>
<head>
<title>jQuery Input Blank</title>
<script type="text/javascript" src="js/jquery-1.10.1.js"></script>
<script type="text/javascript">
function validate()
{
$(document).ready(function(){
$("#button").click(function(){
if($.trim($("#name").val()) == ""){
alert("Name cannot be blank");
return false;
}
});
});
}
</script>
</head>
<body>
Name:<input type="text" id="name" name="name" />
<input type="button" id="button" name="button" value="Submit" onclick="validate()" />
</body>
</html>
Regards & Thanks.