html form required attribute field -
my form not honoring required
attribute of "comments" field. want when user submits form, shows "please fill field", instead user can submit form straight away.
<form class="form-part" method="post" action="contact_form.php" name="contactform" id="contactform" onsubmit="return checkform1();"> <input id="name" type="text" name="name" size="30" title="name" required> <input id="email" type="text" name="email" size="30" title="email" required> <textarea rows="3" id="comments" name="comments" cols="40" title="tell think!" required></textarea> <input type="submit" name="submit" alt="send"> </form>
a simple check function might be:
function checkform1(frm){ if (frm.comments.value==''){ alert('please leave comment.' ); return false; else return true; }
for work need augment form tag to:
<form ... onsubmitt="return checkform1(this)">
Comments
Post a Comment