0

Hi,

When i click on submit button, javascript is going to check a particular textbox if it is empty. If it is then don't validate the form and make a text message visible from invisible. How can i do it? No CSS please.

thanks

<form name="form1" method="post" action="a.html" onsubmit="return validator()">
<span id="tobeVisible" style="visibility:hidden">Enter your message ulen!</span>
<input type="text" name="textMessage"><br>
<input type="submit" value="Submit">
</form>
2
Contributors
2
Replies
4
Views
8 Years
Discussion Span
Last Post by veledrom
0

Here you go:

<script type="text/javascript">
function validator(){
var valid = true;
if (document.form1.textMessage.value=='')
	{
	document.getElementById('tobeVisible').style.visibility='visible';
	valid=false;
	}
	return valid;
}
</script>
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.