Step1: JavaScript for Form Validation
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
<script type="text/javascript"> function validateform(form1) { if("" == document.forms.form1.name.value) { alert("Please enter your name") form1.name.focus() return false } if("" == document.forms.form1.email.value) { alert("Please enter your email") form1.email.focus() return false } if("" == document.forms.form1.message.value) { alert("Please enter your message") form1.message.focus() return false } } </script> function validateform(form1) { if("" == document.forms.form1.name.value) { alert("Please enter your name") form1.name.focus() return false } if("" == document.forms.form1.email.value) { alert("Please enter your email") form1.email.focus() return false } if("" == document.forms.form1.message.value) { alert("Please enter your message") form1.message.focus() return false } } |
Step 2:
Create an HTML form to collect information about Name, Email, Message.