Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 7 of 7
  1. #1
    Junior Member Aquatic's Avatar
    Join Date
    Aug 2003
    Location
    UK
    Posts
    11
    Member #
    2526
    Hi,

    I'm making this form for my guests to fill in and send to me. Could you please tell me what script I need to put in so that a popup saying "please fill in all the fields" would come up when they havn't completed the whole form?

    Thanks in advance.

  2.  

  3. #2
    WDF Staff smoseley's Avatar
    Join Date
    Mar 2003
    Location
    Boston, MA
    Posts
    9,729
    Member #
    819
    Liked
    205 times
    I wrote a tutorial for this here --> http://www.webdesignforums.net/thread7885.html

  4. #3
    Junior Member Aquatic's Avatar
    Join Date
    Aug 2003
    Location
    UK
    Posts
    11
    Member #
    2526
    Thanks but could you tell me what the plain javascript is please? I've already made my forum and got the processing script. I'm not advanced enough yet with javascript to fish out the code myself.

  5. #4
    JR
    JR is offline
    Senior Member JR's Avatar
    Join Date
    Nov 2002
    Location
    UK
    Posts
    4,354
    Member #
    257
    Are you using PHP to process the form? I could help you if you are, but not today, I am going to bed in a minute.
    JR

  6. #5
    Junior Member Aquatic's Avatar
    Join Date
    Aug 2003
    Location
    UK
    Posts
    11
    Member #
    2526
    The script I was planing on using is Perl.

    Is the script for the popup in the processing script or in the form script? I thought it was in the form script.

    As you probably notice I'm a newbie to most aspects of web design.

  7. #6
    Junior Member Aquatic's Avatar
    Join Date
    Aug 2003
    Location
    UK
    Posts
    11
    Member #
    2526
    Anyone?

  8. #7
    Junior Member
    Join Date
    Aug 2003
    Location
    North Carolina
    Posts
    3
    Member #
    2610
    You are looking for a form validation script. This is the one I use:
    Code:
    function validate_form(the_form) {
    	for (i = 0; i < the_form.elements.length - 1; i++) {
    		var the_element = the_form.elements[i];
    		var the_text = the_element.value;
    		var the_alt = the_element.alt;
    		var the_title = the_element.title;
    		var the_tagname = the_element.tagName;
    		if (the_text == '' && the_alt != 'optional' && the_tagname != 'SELECT') {
    			the_element.focus();
    			if(the_title != '') {
    				alert('Please include your ' + the_title + '!');
    			} else {
    				alert('Please complete the form!');
    			}
    			return false;
    		}
    	}
    	return true;
    }
    Here is a sample form that works with the script. You should be able to customize it to suit your needs.:
    Code:
    <form onsubmit="return validate_form(this)">
    First name: <input title="first name"><br>
    Last name: <input title="last name"><br>
    Favorite color: <select><option>red</option><option>blue</option></select><br>
    Comments: <textarea title="comments"></textarea>
    <input type="submit">
    </form>


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 08:17 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2020 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com