dcsimg
www.webdeveloper.com
Results 1 to 3 of 3

Thread: JS validation loop breaks form?

Hybrid View

  1. #1
    Join Date
    Oct 2012
    Posts
    2

    JS validation loop breaks form?

    Hi,

    I have a form on a page with a javascript validation function that loops through each field to test for a value before allowing the form to be submitted:
    http://www.anyware.co.nz/jobadmintest.php

    It works fine in Firefox and Chrome, but in IE the form does not show. I think because there's a problem with the JS validation function "checkAll" just before the form on line 113:

    function checkAll(formObj)
    {
    var obj = document.forms[formObj];
    //alert(obj.name + " " + obj.length);
    for (i=0; i<obj.length; i++)
    {
    if ((obj[i].value == "") & (obj[i].type != "hidden"))
    {
    obj[i].focus();
    //alert("Name: " + obj[i].name + ", Type: " + obj[i].type);
    alert("Please enter a value for all fields.");
    return false;
    }
    }
    document.forms[formObj].submit();
    }

    Can any one suggest why this does not work in IE?

    (I'm using a loop because I have several forms with many fields and I want to test them all.)

    Thanks,
    Phil

  2. #2
    Join Date
    Aug 2008
    Location
    Sweden
    Posts
    227
    Not sure if it's the actual problem but try changing your "&" with "&&". A single ampersand is used for bitwise comparison, while two is for normal logical comparison.

    true && false == false
    0101 & 0011 == 0001
    Last edited by ReFreezed; 10-23-2012 at 11:48 AM.

  3. #3
    Join Date
    Oct 2012
    Posts
    2
    Thanks, have changed & to && and nothing changed.

    Any other suggestions please?

    Thanks,
    Phil

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles