Alert for missing information

Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Reply

Join Date: Sep 2008
Posts: 4
Reputation: pletch99 is an unknown quantity at this point 
Solved Threads: 0
pletch99 pletch99 is offline Offline
Newbie Poster

Alert for missing information

 
0
  #1
Sep 24th, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 1,076
Reputation: Shanti Chepuru is on a distinguished road 
Solved Threads: 98
Shanti Chepuru's Avatar
Shanti Chepuru Shanti Chepuru is offline Offline
Veteran Poster

Re: Alert for missing information

 
0
  #2
Sep 25th, 2008
post your appropriate code....
Be intelligent, But Don't try to cheat.. Be innocent But Don't get cheated..
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 4
Reputation: pletch99 is an unknown quantity at this point 
Solved Threads: 0
pletch99 pletch99 is offline Offline
Newbie Poster

Re: Alert for missing information

 
0
  #3
Sep 25th, 2008
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>
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 954
Reputation: essential will become famous soon enough essential will become famous soon enough 
Solved Threads: 131
Featured Poster
essential's Avatar
essential essential is offline Offline
Posting Shark

Re: Alert for missing information

 
0
  #4
Sep 25th, 2008
Lets head back to the basic! Hope this 1 wil help you! Good day!

  1. <html>
  2. <head>
  3. <title><!--Sample--></title>
  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>
  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>
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum


Views: 762 | Replies: 3
Thread Tools Search this Thread



Tag cloud for JavaScript / DHTML / AJAX
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC