Jump to content

Archived

This topic is now archived and is closed to further replies.

Revlet

[SOLVED] architecturalinstallationteam.com onsubmit validation problem

Recommended Posts

OH, my bad. Feel free to call me stupid.

 

var frm_err = document.getElementbyId("form_errors");
function validateForm (frm) {
   var errors = [], errno = 0;
   if (!/^[a-z]+$/i.test(frm.Name.value)) errors[errno++] = "Name is required and can only contain letters.";
   if (!/^[a-z\d]+$/i.test(frm.Title.value)) errors[errno++] = "Title is required and can only contain letters and numbers.";
   if (!/^[a-z\d]+$/i.test(frm.Company.value)) errors[errno++] = "Company is required and can only contain letters and numbers.";
   if (!/^[-.+_\da-z]+@[-.\da-z]+\.[a-z]{2,4}$/.test(frm.Email.value)) errors[errno++] = "Email is required.";
   if (errno == 0) return true;
   frm_err.style.display = "block";
   frm_err.innerHTML = "<ul><li>" + errors.join("</li><li>") + "</li></ul>";
   return false;
}

 

Now the code simply doesn't validate... :(

 

Just lets blank fields through

Share this post


Link to post
Share on other sites

Oh, I misspelled document.getElementById. You can fix that.

 

And FYI, there was an error. Unlike PHP, you just don't see it on the page. It's like a HTML error.

 

 

It didn't make a difference capitalizing the B. Still doesn't work :(

Same error as before. Capitalize B for me.

Share this post


Link to post
Share on other sites

Oh, I misspelled document.getElementById. You can fix that.

 

And FYI, there was an error. Unlike PHP, you just don't see it on the page. It's like a HTML error.

 

 

It didn't make a difference capitalizing the B. Still doesn't work :(

Same error as before. Capitalize B for me.

 

 

YES! everything now works perfectly the way it should.  ;D  ;D  ;D

 

Thank you again VERY VERY much for your help! Sorry for being a pain and asking for the error div in addition...

 

 

- Revlet

Share this post


Link to post
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.