How can I fix this form’s code?

9th of April 2014 0

How can I fix this form’s code?

I need to make sure that the validation works for the drop down, as well as the email field, and after it’s been validated, i need the script to send it to a page based on the value picked from the drop down list.

here is the code I have so far, it validates, correctly but does not send the user to the right link properly, basically it sends people to the link if they have not filled out the form properly when they click submit, and will not send them there if they actually filled the form out correctly.



Please select an item.



A value is required.Invalid format.
emailer

**** this is the validation code ****

function formValidator(){
// Make quick references to our fields
var state = document.getElementById(‘state’);
var email = document.getElementById(‘email’);

// Check each input in the order that it appears in the form!

if(madeSelection(state, “Pick an item”)){
if(emailValidator(email, “Please enter a valid email address”)){
return true;

}

}

return false;

}

function madeSelection(elem, helperMsg){
if(elem.value == “Select an Item”){
alert(helperMsg);
elem.focus();
return false;
}else{
return true;
}
}

function emailValidator(elem, helperMsg){
var emailExp = /^[w-.+]+@[a-zA-Z0-9.-]+.
[a-zA-z0-9]{2,4}$ /;
if(elem.value.match(emailExp)){
return true;
}else{
alert(helperMsg);
elem.focus();
return false;
}
}

Hi Ron, thank you so much for your quick reply, however I don’t need a contact form i am looking for a form that can just send the people off to another page of mine depending on their selection. for example if they select 1 from drop down they go to page1 if 2 then page2 but i also need there to be validation so that they actually do pick a value and also that they input their email.

Best answer:

Answer by Necrotizing Fasciitis
Not gonna work as coded. Your current hosting package or service MUST allow SMTP ( http://en.wikipedia.org/wiki/Simple_Mail_Transfer_Protocol ) to work. Otherwise, no email can be sent.

PHP: Sending Email Tutorial (Text/HTML/Attachments): http://www.webcheatsheet.com/php/send_email_text_html_attachment.php

Use any of the below sites to make the workable form you need:

These are really good online form makers. Just follow the instructions for making it and uploading file(s).

How to Make a Slick Ajax Contact Form with jQuery and PHP: http://www.elated.com/articles/slick-ajax-contact-form-jquery-php/

Contact Form Generator: http://www.tele-pro.co.uk/scripts/contact_form/
WYSIWYG Form Maker: http://www.jotform.com/?gclid=CNKhqei1wJ4CFRQhnAod6laUqA

http://www.thesitewizard.com/wizards/feedbackform.shtml

http://www.form2email.net/

http://www.phpform.org/

http://www.thepcmanwebsite.com/form_mail.shtml

http://emailmeform.com/

More…

Add your own answer in the comments!

Filed under § jquery forms — Tagged with , ,

Share it!

Was it good for you to?

Sponsors

Support for the site!

No sponsors at the moment.



Your opinion matters. Add it below.


Tip: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Recent comments

Categories



Copyright jqueryui.info since 2010. All rights reserved. Design and the Absolute Theme by Tommie Hansen.