Jump to content

Desperate - Contact Form Validation with Savvy UI


clee109

Recommended Posts

I'm sorry if this has been posted before, my skills are noob at best in these areas and if this topic has been discussed please point in that direction, I tried search and nothing came up to help. 

 

I'm desperate, I have a savvyui script that validates my form fields, if you don't fill in a required field it prompts you for that field, that works great.  When you hit submit though, the success function does not work.  I can't understand if it's the javascript not firing or the PHP contact script not firing.  Both I don't have a super firm knowledge of.  Maybe one of you knows the answer off the top of your head and would not mind sharing it with me. 

 

When you hit submit I do get the email with the form fields like it should send, just no success message.

 

Here is the code the javascript and form:

<form id="contact-form">
                        <p>* Denotes a required field</p>
					<div class="container">
						<label>* Your Name:</label>
						<input type="text" name="contact_name" class="required"/>
					</div>
					<div class="container">
						<label>* Your E-mail Address:</label>
						<input type="text" name="contact_email" class="email required"/>

					</div>
					<div class="container">
		            	<label>Subject:</label>
						<select name="contact_subject" id="contact_subject">
							<option value="Freelance Job">Freelance Job</option>
							<option value="Contract">Contract</option>
                                <option value="General">General</option>
						</select>
					</div>
					<div class="container">
						<label>Nature Of Work:</label>
						<select name="contact_task" id="contact_task">
							<option value="Web Design">Web Design</option>
							<option value="Graphic Design">Graphic Design</option>
                                <option value="Print Design">Print Design</option>
						</select>
					</div>

					<div class="container">
						<label>Type Of Work:</label>
						<select name="contact_type" id="contact_type">
							<option value="Personal">Personal</option>
							<option value="Corporate">Corporate/Commercial</option>
                                <option value="Other">Other</option>
						</select>

					</div>

                        <div id="show-if-corporate">

                            <div class="container">
							<label>What is your company name?</label>
							<input type="text" name="corporate_company"/>
						</div>
						<div class="container">
							<label>Do you need branding development?</label>
							<input type="text" name="corporate_logo"/>
						</div>
						<div class="container">
							<label>How many pages will be designed?</label>
							<input type="text" name="corporate_page"/>
						</div>
						<div class="container">
							<label>Do you need a CMS?</label>
							<input type="text" name="cms"/>
						</div>
					</div>

                        <div class="container">
						<label>This Work Is:</label>
						<select name="contact_remark" id="contact_remark">
							<option value="New">A New Project</option>
							<option value="Redesign">A Redesign</option>

						</select>
					</div>

					<div class="container">
						<label>What's your favorite site URL?</label>
						<input type="text" name="contact_reference" />
					</div>

					<div class="container">
						<label>Your budget:</label>
						<select name="contact_budget" id="contact_budget">
                            	<option value="$500 - $1,000">$500.00 - $1,000</option>
							<option value="$1,000 - $1,500">$1,000 - $1,500</option>
							<option value="$1,501 - $2,000">$1,500 - $2,000+</option>
						</select>
					</div>
					<div class="container">
						<label>* When do you plan to start?</label>
						<input type="text" name="contact_start" class="required"/>
					</div>
					<div class="container">
						<label>* What is your ideal due date?</label>
						<input type="text" name="contact_end" class="required"/>
					</div>
					<div class="container">
						<label>Anything else I should know?</label>
						<textarea name="contact_other" rows="12"></textarea>
					</div>

					<div>
		            	<input type="submit" name="contact-submit" value="Submit" id="submit" />
					</div>

			</form>
                <script type="text/javascript">
			<!--
			Js.setup.util.editable({title: "Key in the custom value"});

			var contactBox = window.contactBox = {
				contact: {
					task: function() {
						var node = jQuery("#contact_type");
						var child = jQuery("#show-if-corporate");

						var task = function() {
							if (node.val() == "Corporate") {
								child.slideDown();
							}
							else {
								child.slideUp();
							}
						};

						node.bind("change", function() {
							task();
						});
						task();
					},

					success: function(text) {
						jQuery("#contact-form").slideUp();
						jQuery("<h3/>").text("Thank You").appendTo("#col_670");
						jQuery("<p/>").text("I will get back to you shortly.").appendTo("#col_670");
					}
				}
			}
			jQuery(function() {

				new Js.util.editable("#contact_subject");
				new Js.util.editable("#contact_task");
				new Js.util.editable("#contact_type");
				new Js.util.editable("#contact_budget", {
					prefix: "$ "
				});

				contactBox.contact.task();



				new Js.util.formSubmit({
					id: "#contact-form",
					url: "contact_me.php",
					option: {
						onError: function(){
							alert("Please fill in all required fields (marked by *)");
						}
					}
				});
			});
			-->
			</script>

 

and here is the PHP:

 

<?php 
$name = $_POST['contact_name'];
$email = $_POST['contact_email'];
$subject = $_POST['contact_subject'];
$task = $_POST['contact_task'];
$type = $_POST['contact_type'];
$company = $_POST['corporate_company'];
$branding = $_POST['corporate_logo'];
$pages = $_POST['corporate_page'];
$cms = $_POST['cms'];
$project = $_POST['contact_remark'];
$redesign = $_POST['redesign_url'];
$favorite = $_POST['contact_reference'];
$budget = $_POST['contact_budget'];
$start = $_POST['contact_start'];
$due = $_POST['contact_end'];
$comments = $_POST['contact_other'];


//Send Mail Settings
$to = 'blank@blank.com';
$subject = 'Website Contact';
$message = "Name: $name \n E-mail: $email \n Subject: $subject \n Task: $task \n Type: $type \n Company Name: $_company \n Needs Branding: $branding \n Number Of Pages: $pages \n Need a CMS: $cms \n Type Of Project: $project \n Exisiting Page URL: $redesign \n
		Favorite Website: $favorite \n Budget: $budget \n Start Date: $start \n End Date: $due \n Comments: $comments \n";
mail($to, $subject, $message);

?>

 

Thank you so much, I really appreciate it!!!!!

 

-Chris

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.