Phoenix917 Posted August 20, 2008 Share Posted August 20, 2008 Hey, guys! I have a simple question I can't seem to find the answer to.... If someone's posted it, it won't come up in my results! I simply want to validate a textarea box as I have input (regular text) boxes in my form. For some reason, textareas don't seem to like the same coding! Any suggestions? I wrote the validation for the textarea the same as I did for my input boxes: if (doc.txtComment.value.length == 0) { alert("Did you go through all this work for nothing? I didn't think so. Please enter a comment."); doc.txtComment.focus(); doc.txtComment.select(); return false; } The html for the textarea is: <td><label><div align="left"> <textarea name="txtComment" cols="30" rows="5" id="txtComment"></textarea> </div></label></td> What should be different from the input boxes to make it work? Thanks!! Quote Link to comment Share on other sites More sharing options...
akitchin Posted August 20, 2008 Share Posted August 20, 2008 technically, the textarea has no "value" attribute, which is why your length always evaluates to 0 (if at all, since that should throw a "property not found" error in JS). you would probably be more interested in looking at the innerHTML property, for which there's a bit of documentation courtesy of w3schools below: http://www.w3schools.com/htmldom/prop_anchor_innerhtml.asp you can probably find more helpful technical knowledge in a JS reference website, but hopefully this helps you along. Quote Link to comment Share on other sites More sharing options...
Phoenix917 Posted August 20, 2008 Author Share Posted August 20, 2008 I just found it! When you create a textarea, it has automatically has no "type" attribute. So.... I just added the "type" value and voila! <td><label><div align="left"> <textarea name="txtComment" type="text" cols="30" rows="5" id="txtComment"></textarea> </div></label></td> I can't believe I finally figured it out! *sigh* Newbie overlook...lol...Thanks. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.