Fun Leprechaun
04-08-2009, 05:04 AM
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!:D
abduraooft
04-08-2009, 08:46 AM
It's not working in FF2 either. I don't see any validation script on your site.
Sorry, I missed it.
Old Pedant
04-08-2009, 09:07 AM
HUH? The validation is right there in the file. Code such as:
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:
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.