Jump to content

[SOLVED] architecturalinstallationteam.com onsubmit validation problem


Revlet

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

Link to comment
Share on other sites

  • Replies 52
  • Created
  • Last Reply

Top Posters In This Topic

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.

Link to comment
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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • 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.