SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    PHP warrior dkode's Avatar
    Join Date
    Sep 2001
    Location
    Planet Namek
    Posts
    329
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Dynamically create js client side validation

    I am creating the following using an array called $validate

    Code:
    <script Language="JavaScript">
    
    function validateForm(theForm) {
    
    		if (!validRequired(theForm.form[company_name],"Company Name",true)) return false;
    			if (!validRequired(theForm.form[contact_name],"Contact Name",true)) return false;
    			if (!validRequired(theForm.form[phone_number],"Phone Number",true)) return false;
    			if (!validRequired(theForm.form[address],"Address",true)) return false;
    			if (!validRequired(theForm.form[city],"City",true)) return false;
    			if (!validRequired(theForm.form[zip],"Zip",true)) return false;
    	
    	return true;
    }
    </script>
    Each field in my form is set to: form[field_name]. This is so when they submit I can grab the form array and it has all the fields they submitted. This seems to cause a problem with this javascript. It gives me an error at the first validRequired where form[company_name] is. Does anyone know what the problem could be?

  2. #2
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ummm YEAH - where's the function validRequired ?!?!


    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •