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.


<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">

Recommended Answers

All 2 Replies

Here you go:

<script type="text/javascript">
function validator(){
var valid = true;
if (document.form1.textMessage.value=='')
	return valid;

Thank you buddy.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.