Can anyone help with checking if value exists?
I need to check that name, telephone,email and enquiry have a value in the form below before submitting the form when the button is clicked…If there is no value need to display an error message.
This is my form:
<form action="#" id="emailForm" method="post">
<div class="left">
<input type="hidden" value="1" name="submitted">
<input type="text" onblur="if(this.value==''){this.value='name'};" onfocus="if(this.value=='name'){this.value=''};" class="inputField" value="name" name="contactname"><br>
<input type="text" onblur="if(this.value==''){this.value='telephone number'};" onfocus="if(this.value=='telephone number'){this.value=''};" class="inputField" value="telephone number" name="telno"><br>
<input type="text" onblur="if(this.value==''){this.value='email address'};" onfocus="if(this.value=='email address'){this.value=''};" class="inputField" value="email address" name="email"><br>
</div>
<div class="right">
<textarea rows="10" cols="10" onblur="if(this.value==''){this.value='enquiry'};" onfocus="if(this.value=='enquiry'){this.value=''};" class="textarea" name="enquiry">enquiry</textarea>
<br>
<button class="send"></button>
</div>
</form>
Any help is much appreciated…
If you
return falseit will stop the form sending… 🙂Its the same as with links…
$('a').click(function(){ return false; });