Web Analytics Made Easy -
StatCounter Javascript Form Validation Code - not working in IE7 - CodingForum

Announcement

Collapse
No announcement yet.

Javascript Form Validation Code - not working in IE7

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Javascript Form Validation Code - not working in IE7

    Hi there,

    Can someone take a look at the following javascript code for form validation - it's working great in Firefox, Safari & Opera however, it doesn't work in IE7 although the form can still be used and submitted etc, it doesn't prompt when a field is left blank.

    Here's the url:

    http://www.saponelawfirm.com/contact.html

    What do I need to do in order to make it work in IE7?

    Many, many thanks!

  • #2
    It's not working in FF2 either. I don't see any validation script on your site.

    Edit: Sorry, I missed it.
    Last edited by abduraooft; Apr 8, 2009, 04:20 AM.
    Digitalocean Cloud Hosting (Referral link - get $10 free credit) Fameco

    Comment


    • #3
      HUH? The validation is right there in the file. Code such as:
      Code:
      			function validate(){
      				var form=this
      				clearErrors(form)
      				shrinkMyFields(form)
      				if (form.FirstName.value.match(justWhiteSpace)) error(form.FirstName,"First name is required.")
      				if (form.LastName.value.match(justWhiteSpace)) error(form.LastName,"Last name is required.")
      				if (!form.email.value.match(validEmail)) error(form.email,"Please enter a valid email address.")
      				if (form.comments.value.match(justWhiteSpace)) error(form.comments,"A comment is required.")
      				return noErrors()
      			}
      It certainly is a very complex set of validation for such a simple little form, so I assume it's some sort of generic code lifted en masse for the purpose.

      It works, mostly, in FF3. I had it submit the form one time even though I had no email address given. A glitch of some kind.

      AHHH! Found it.

      MSIE says "object does not support this property or method" for the line:
      Code:
      	for(var errorFields=form.getElementsByClassName('error-present'),i=errorFields.length-1;i>=0;i--){
      And, indeed, the MSIE reference docs do *NOT* list getElementsByClassName as a method, anyplace.

      So...back to the drawing board, a little. Should be easy enough to work around this. Get all the relevant elements by some other means (by tag name?) and then just check the .className property for a match.
      Be yourself. No one else is as qualified.

      Comment

      Working...
      X