943,719 Members | Top Members by Rank

Ad:
Sep 24th, 2008
0

Alert for missing information

Expand Post »
Hi, I'm new to Javascript and I'm having trouble with my function to check for missing information in the code. Any ideas? Thanks
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
pletch99 is offline Offline
4 posts
since Sep 2008
Sep 25th, 2008
0

Re: Alert for missing information

post your appropriate code....
Reputation Points: 137
Solved Threads: 162
Posting Virtuoso
Shanti C is offline Offline
1,641 posts
since Jul 2008
Sep 25th, 2008
0

Re: Alert for missing information

function validate_required(field,alerttxt)
{
with (field)
{
if (value==null||value=="")
{
alert(alerttxt);return false;
}
else
{
return true;
}
}
}

function validate_form(thisform)
{
with (thisform)
{
if (validate_required(first name,"Missing Information!")==false)
{first name.focus();return false;}
}
}


<form action="submitpage.htm"
onsumbit="return validate_form(this)"
method="post">
</form>
Reputation Points: 10
Solved Threads: 0
Newbie Poster
pletch99 is offline Offline
4 posts
since Sep 2008
Sep 25th, 2008
0

Re: Alert for missing information

Lets head back to the basic! Hope this 1 wil help you! Good day!

html Syntax (Toggle Plain Text)
  1. <html>
  2. <head>
  3. <title><!--Sample--></title>
javascript Syntax (Toggle Plain Text)
  1. <script type="text/javascript">
  2. <!--
  3. function validate( form )
  4. { var nameField = form.firstname;
  5. if ( nameField.value == "" ) { alert('\nMissing Information!'); nameField.focus(); return false; }
  6. else { alert('\nDo the next stuff!'); return true;
  7. }
  8. }
  9. //-->
  10. </script>
html Syntax (Toggle Plain Text)
  1. </head>
  2. <body>
  3. <form action="submitpage.htm" name="form1" onsubmit="return validate( this );" method="post">
  4. <input type="text" name="firstname" size="20" value="" /><br />
  5. <input type="submit" value="Submit" />
  6. </form>
  7. </body>
  8. </html>
Featured Poster
Reputation Points: 114
Solved Threads: 138
Posting Shark
essential is offline Offline
973 posts
since Aug 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JavaScript / DHTML / AJAX Forum Timeline: Readonly fields and onchange
Next Thread in JavaScript / DHTML / AJAX Forum Timeline: eliminating active-x warnings for pop-up





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC