Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
can't get js to work with guest book
Old 10-25-2006, 01:46 PM can't get js to work with guest book
jason_bristol's Avatar
Ultra Talker

Latest Blog Post:
New site - ConnectFrench.com
Posts: 310
Name: Jason Eyermann
Location: england bristol
Trades: 0
I some added js to my guest book page. If someone pushes the submit button but does not leave a name I want to inform the viewer that they need to insert a name. I've done that fine but the only problem is that when I then push OK on the pop the page still continues to progress and enteres the viewers entry in.

How can I stop the loading the message being put thourgh.

here is the java script and the formdetails.

thanks for any help

Code:
<script type="text/javascript">
	  
	  function formValidator(){
	var firstname = document.getElementById('moreInfo');
	if(emptyBox(firstname, "Please enter your name.")){
							return true;
						} else {
		return false;
	
}
}
	  function emptyBox(elementJason, returnMessage) {
	       if (elementJason.value.length == 0) {
		         alert(returnMessage);
				 elementJason.focus();
				 return true;
			} else {
			  return false;
		}
		}
		</script>
HTML Code:
<form method="post" name="form1" onsubmit="return formValidator()" action="<?php echo $editFormAction; ?>">
        <table align="center">
          <tr valign="baseline">
            <td width="82" align="right" nowrap class="headerwhite">Name:</td>
            <td width="419"><input type="text" id="moreInfo" name="Name" value="" size="32"></td>
          </tr>
          <tr valign="baseline">
            <td align="right" nowrap class="headerwhite">Location:</td>
            <td><input type="text" name="Location" value="" size="32"></td>
          </tr>
          <tr valign="baseline">
            <td align="right" nowrap class="headerwhite">Email:</td>
            <td><input type="text" name="Email" value="" size="32"></td>
          </tr>
          <tr valign="baseline">
            <td align="right" nowrap class="headerwhite">Website:</td>
            <td><input type="text" name="Website" value="" size="32"></td>
          </tr>
          <tr valign="baseline">
            <td align="right" valign="top" nowrap class="headerwhite">Comments:</td>
            <td><textarea name="Comments" cols="50" rows="5"></textarea>
            </td>
          </tr>
          <tr valign="baseline">
            <td nowrap align="right">&nbsp;</td>
           <td><input type="image" value="Insert record" name="submit" src="../images/submitbutton.jpg"></td>
          </tr>
        </table>
        <input type="hidden" name="MM_insert" value="form1">
      </form>
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
jason_bristol is offline
Reply With Quote
View Public Profile Visit jason_bristol's homepage!
 
 
Register now for full access!
Old 10-25-2006, 08:08 PM Re: can't get js to work with guest book
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,898
Name: Keith Marshall
Location: Connecticut
Trades: 0
You just needed to reverse the true and false order in your function.

Code:
function formValidator(){
  var firstname = document.getElementById('moreInfo');
 if(emptyBox(firstname, "Please enter your name.")){
  return false;
 } else {
  return true; 
  }
}
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 10-26-2006, 11:04 AM Re: can't get js to work with guest book
jason_bristol's Avatar
Ultra Talker

Latest Blog Post:
New site - ConnectFrench.com
Posts: 310
Name: Jason Eyermann
Location: england bristol
Trades: 0
Big thanks mgraphic! It works now.

I'm now going to try and help 3 people on this site with something if I can. I think that should be a moral rule.

I tried to add talkupation but can't because i've already done it before.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
jason_bristol is offline
Reply With Quote
View Public Profile Visit jason_bristol's homepage!
 
Reply     « Reply to can't get js to work with guest book
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.12519 seconds with 12 queries