Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hey Everyone, I am pretty novice at 1

Status
Not open for further replies.

fmrock

Programmer
Sep 5, 2006
510
US
Hey Everyone, I am pretty novice at JS and know you all can help.

I basicly have one text area and a few different submit buttons. Each button means something different. I basicly want to validate the form by.

WHen they click the "Electronic Signature" I need to check the Addendum field to see if its blank or "Please enter your comment." If thats blank, then i need to just alert a message box, which when they click ok.. just takes them back to the form.

But if they acually fill in any info in the addendum field, i would like the js confirm with a msg i create and an OK and Cancel button.

Code:
<form action="update.asp" method="post" name="frmAddendum">

<textarea name="Addendum" id="Addendum" cols="55" rows="5" onClick="clearComments(document.frmAddendum.Addendum)">Please Enter your Comment</textarea>
<br>
<input name="btnSubmit" type="submit" id="btnSubmit" value="Electronic Signature">

</form>
 
Here's a cut and dry example of what you're asking:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml">[/URL]
<head>
<title>test</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<script type="text/javascript">

function validateMe(frm) {
   var ta = frm.elements["theTextArea"];
   if (!ta.value.length) {
      alert("You must fill in the textarea before submitting");
      return false;
   }
   return (confirm("Are you sure you want to submit?"));
}

</script>
<style type="text/css"></style>
</head>
<body>

<form id="theForm" onsubmit="return validateMe(this)">
   <textarea name="theTextArea"></textarea>
   <input type="submit" value="click me" />
</form>

</body>
</html>

-kaht

Lisa, if you don't like your job you don't strike. You just go in every day and do it really half-assed. That's the American way. - Homer Simpson
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top