form verification using regular expressions

I keep getting an error that says item is null. I'm a little lost because once I got my regExp to start working this actually worked for a little bit. When I came back i was getting an error. I have no idea what i did.

var creditExp = /^([345])(\d{3})\-(\d{4})\-(\d{4})\-(\d{4})$/; var creditNumber = document.getElementById("creditnum").value; var item = creditExp.exec(creditNumber); document.getElementById("creditnum").value = item[1] + item[2] + "-" + item[3] + "-" + item[4] + "-" + item[5]; if (item[1] == 4 && document.getElementById("card1").checked == true) { return true; } else if (item[1] == 5 && document.getElementById("card2").checked == true) { return true; } else if (item[1] == 3 && document.getElementById("card3").checked == true) { return true; } else { alert("You must enter a valid credit card number."); document.getElementById("creditnum").focus(); return false; } var billingName = document.getElementById('creditname').value; if (billingName == null || billingName == "") { alert("You must enter your first name as printed on your credit card!"); document.getElementById('creditname').focus(); return false; }

Posted On: Monday 26th of November 2012 10:09:37 PM Total Views:  261
View Complete with Replies

Related Messages:

calculating form problem   (154 Views)
I posted this on the web development forum and did get headed in the right direction, but it looks like it should be here as another member suggested.... I have a calculating order form, which is at which I partially inherited. The problem is that the second drop down "select item" was added, and is not part of the calculation, in order to get needed information to an html template for emailing the order information. Right now it is possible to have the "widget" choice be the wrong one (not corresponding with the select size choice,) in that you could have a "widget1" show up at the price of a "widget2" which is not good. Is there a way to report two values, or another value of information from the 3rd drop down This would eliminate the need for the second. OR how do I require the second drop down "select item" selection is made, and it corresponds to the proper selection in the third "select size." of the lines can not be required though, as the user may not be ordering more than one item. Obviously I'm not a programmer, I am actually a hardware/network tech. This is in my lap to deal with though.
Using AJAX results in PHP form   (94 Views)
! I'm having some problems with using data in an PHP form I'm working on that utilizes AJAX. Could be a beginner's mistake, but, then again, it might not be... :) SCENARIO: I have a form with two sets of fields, origin country, city, state, and zip, and destination country, city, state, and zip. In each set, the country drop-down is only visible (options are USA, Canada, and Mexico) until the user selects a country, after which they see a text field for city, another drop-down with a listing for all the states in the country they've selected, and a text field for zip code. Before they select a country, in place of the city, state, and zip fields, all they see is a line of text, asking the user to select a country. The AJAX portion of the menu seems to work fine. When you select a country, the city, state, and zip fields show up, as they're supposed to. However, after filling them out, and submitting the form, it tells me that I didn't fill out the required fields of origin city, state, and country. After loading the page, and checking the source, I'm finding that, even though the page is displaying the fields, the source still thinks that the "please select a country" text is still there. So, it seems that my problem is getting the form fields to actually *insert* into the form, and not just display. The three files I use for this are add.php, getstates.php and selectstate.js First, here is add.php, the main form (or at least the form with as much extraneous info removed as I could): $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "" . htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form2")) { $insertSQL = sprintf("INSERT INTO Loads (Origin_Country, Origin_City, Origin_State, Origin_Zip, Dest_Country, Dest_City, Dest_State, Dest_Zip) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)", GetSQLValueString($_POST['Origin_Country'], "text"), GetSQLValueString($_POST['Origin_City'], "text"), GetSQLValueString($_POST['Origin_State'], "text"), GetSQLValueString($_POST['Origin_Zip'], "text"), GetSQLValueString($_POST['Dest_Country'], "text"), GetSQLValueString($_POST['Dest_City'], "text"), GetSQLValueString($_POST['Dest_State'], "text"), GetSQLValueString($_POST['Dest_Zip'], "text")); mysql_select_db($database_Connection, $Connection); $Result1 = mysql_query($insertSQL, $Connection) or die(mysql_error()); $insertGoTo = "member_profile.php"; if (isset($_SERVER['QUERY_STRING'])) { $insertGoTo .= (strpos($insertGoTo, '')) "&" : ""; $insertGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $insertGoTo)); } Origin Country: Select country United States Canada Mexico City, State, and Zip: Select a country to view origin options. Destination Country: Select country United States Canada Mexico City, State, and Zip: Select a country to view destination options. Next is getstates.php, the code that is supposed to be inserted into the form when the user selects a country (but it only seems to display the fields, not insert them into the form, so that they can be used):     
textarea with formatting   (124 Views)
i have searched the web for awhile on this... i wrote a script that will format certain words as the user types [INDENT](ex. when the user types MTrak the text is replaced with MTrak)[/INDENT] i need to know how to view the formatting in a text box, not the tags. i dont want a full WYSIWYG editor because the end result of the script will be something like editing scripts in dreamweaver (functions are a different text color that regular text, etc.) i have already written the javascript to remove the formatting when the form is submitted. does anyone have a simple solution
Need help with form submission   (183 Views)
, I am designing my website and I want people visiting my site to be able to submit a form. However, if they submit a form, I would like to require certain information to be submitted. I got a script from Dynamic Drive that is supposed to do that but here is the problem. Inside the form tag it has this code-"form name="formcheck" onsubmit="return formCheck(this); " As you can see, there is not a "Action" or "Method" shown. So can someone tell me what I will need to do to cause this script, if form validation occurs, to send me the info from form in an E-Mail. Thank you.
customize eperformance page   (251 Views)
is there anyone whose familiar with ePerformance page in PeopleSoft I need to make the left navigation and header fixed when scrolling up or down. Is there a javascript or some sort of a code that is applicable in PeopleSoft to make this functionality possible
javascript required fields 290 form elements   (203 Views)
I am constructing survey page for a client, and it's getting extremely long winded. There are 290 questions and all are required. This means, typing out huge amounts of stuff, obviously, but, I was wondering if there was a sort of "easier" way to do this. This survey is one of those types that, like 10 questions are asked, you go to the next page and 10 more questions are asked. I have method post on these forms and using PHP to pass post values and send to hidden fields. The database is not filled with the information until the very last page. So far, I have all of that functionality figured out, but, I need to figure out how to make it so that, if the user skips a question, for them to be told so before going to the next page. Further, all previouse data needs to be saved, without using the database to store it. The reason for this is because the user can not recieve a user id until finishing the survey. Any sort of cheat script out there that says "check all fields and see if they aren't null"
form field value change onclick   (117 Views)
How do I change the value for a field in my form when sombody clicks in that field for example i have a field for "name" and it should say "name" in it, but when you click in it the value changes to nothing.
Can I have a form without having an associated file.   (240 Views)
In every book I have on HTML, it shows a database or other file associated with a form. I want to use form elements with JavaScript to control the web pages themselves, without the use of an external file. Can this be done
how can i format a text field value with commas in?   (269 Views)
i have 5 fields that show a numeric amout. dem2textbox.text iif2textbox.text fir2textbox.text fab2textbox.text net2textbox.text allow me to format the value from example 1000 to 1,000 using this code. wn = iff2TextBox.Text iff2TextBox.Text = wn.ToString("N0") fields names below shortened for example. my javascript gets run any time iif2, fir2 or fad2 fields get changed. originally i did not have the field formated with commas and the script ran net2 = parsint(dem2) - parsint(iif2) - parsint(fir2) - parsint(fab2); but users want it to show commas. then i found out parsint can not handle "," as a field value of 750,123 would now come back with 750 so i now had to used "remove" command to remove commas (is there a better way). but i can not seam to find a javescript command to set the value of the field to show commas. am i just blind is there a better way of doing this i would think javascript could handle something as basic as this. TIA
Passing an Array to a form field   (76 Views)
, I am trying to pass a js array ,Round1[], to a form and send it. I can get it to work with serialized values but I want to send the data as an array. The arrays are filled with ...
I have TEXTAREA form, i want to add DROP DOWN LIST BOX beside it   (149 Views)
Hi i have comment form code (in black colour) below, user type the comment in TEXTAREA, and click the Submit button i want to add DROP DOWN LIST BOX before it, that user can choose, and add that DROP DOWN value with the text in TEXTAREA into database, so just like prefix in forum i already tried below code (in red), but still not working, please help what is the right code $(document).ready(function(){ $("#form_submit").click(function() { document.getElementById("form_submit").disabled = true; checkcomment = trim(document.comment_form.message.value); if (checkcomment.length > 0) { var msgPrefix = document.forms["comment_form"].elements["message_prefix"].options[document.forms["comment_form"].elements["message_prefix"].selectedIndex].value; value = "["+msgPrefix+"] "+value; comment_submit(); } else { alert("Please type some text"); } document.getElementById("form_submit").disabled = false; }); function comment_done() { } function comment_submit() { $.ajax({ type: "POST", url: "/targetfile.php", data: $("#comment_form").serialize(), success: function(data){ if (data == "SUCCESS") { //alert("Successful"); document.comment_form.message.value = ""; setTimeout (CommentAjax,0); } else { alert("Error: "+data); } } }); } }); One Two Three This post has been edited by JackOfTrades: 24 September 2012 - 03:38 AM Reason for edit:: Changed quote tags to code tags, removed color tags
Questions on getting a web form   (278 Views)
I am working on adding a web form for comments on a website I am working on. I have the form that should email information to my email, but I cannot get it to work. Because I use a drop down list as part of it, I think I need to add Javascript to get all the information to email to me, can someone point me in the right direction Name: Are you a member of a film troop or group  Yes   Email: Who is your comment for : Parker George Extras Everyone That guy in the hat Waldo Anyone who will listen A missed connection What have you got to say Submit  Reset
Javascript form validation validate and redirect on submit thanks page   (125 Views)
! I am trying to make form in dreamweaver with several text boxes. If the person doesn't fill out one or more of the boxes, I want an error message to come up which lists which boxes weren't filled out. If they ARE filled correctly, I want the page to redirect to a thanks page. This isn't online, and I'm new to coding. But its going ok, I just can't get the form to validate AND redirect if return true (or something ). I don't know how to do that. I've tried googling it, searching youtube tutes, and reading a few javascript books, but no joy. Pleeeeeeease help! Thanking you in advance... PS Here is a site that has the kind of error message I want; it tells the user which boxes aren't filled in, all in one error message. Here's the form: (Please note, there is a select option box, a box with pre-entered text that dissapears onclick with a max character limit, and 2 pre-checked tick boxes. There are also several plain enter text boxes, including one for email, which I want to be in the format of an email, as in, include an "@" and a ".", be in the right order, etc.) Form You will need to complete all sections to post. The more accurate and detailed your input, the better. Select type Please select Architectural Services Bathroom Fitting Bricklaying Carpentry & Joinery Carpet Fitting Chimneys & Fireplaces Conservatories Conversions - general Damp Proofing Demolition & Clearing Driveways Electrical Extensions Fencing Flooring Garages & Sheds Gas Work Groundwork & Foundations Handyman Central Heating Insulation Kitchen Fitting Landscape Gardening Loft Conversions New Builds Painting & Decorating Plastering Plumbing Restoration & Refurbishment Roofing Security Systems Stonemasonry Tiling Tree Surgery Windows Describe Job title: For example: Plaster ceiling 12x12ft Gas fire installation & boiler service Painting 3 rooms Describe what needs to be done e.g. Need a new front door. About 36" by 80". Needs to be done before 5th March. Pine with 20" x 15" frosted glass window at top. Experienced carpenter required. (Maximum characters: 500) You have characters left. The better your description, the more interest you're likely to get. Try to include: Sizes (Exact or rough) When you would like the work done Preferred materials Specific skills required Please don't put any contact details into this publicly viewable section. Postcode (UK) Full postcode of the location where work is to take place. This will be used to create a map of the location. Register with findacarpenter Your name Phone number Choose a username Email I'd like the monthly newsletter I agree to the terms and conditions You will need to complete all sections to post. The more accurate and detailed your post, the easier it will be for traders in your area to find you. Please make especially sure your phone number is correct as traders can contact you faster by phoning you. Here's the javascript: function checkFields() { missinginfo = ""; if (test6.myform.jobtitle.value == "") { missinginfo += "\n - Job Title"; } if (test6.myform.postcode.value == "") { missinginfo += "\n - Postcode"; } if (test6.myform.fname.value == "") { missinginfo += "\n - Full Name"; } if (test6.myform.phonenumber.value == "") { missinginfo += "\n - Phone Number"; } if (test6.myform.username.value == "") { missinginfo += "\n - Username"; } if (( == "") || ('@') == -1) || ('.') == -1)) { missinginfo += "\n - Email address"; } if (test6.myform.limitedtextarea.value == "") { missinginfo += "\n - Job Details"; } if ( == 0) { missinginfo += "\n - Select a Department"; } if (missinginfo != "") { missinginfo ="_____________________________\n" + "Please complete correctly the following fields:\n" + missinginfo + "\n_____________________________" + "\nPlease re-enter and submit again!"; alert(missinginfo); return false; } else return true; }
AJAX loading of next question in form not working   (110 Views)
So, my javascript: function stopselect(county) { request = new XMLHttpRequest();'GET',concat('warnajax.phpcounty=',county),false); request.send(); document.getElementById("stopselection").innerHTML=request.responseText; } I have checked, and the event catch most definitely works and this function is called. warnajax.php is extremely simple: The code that prints the form in question looks like: I'm an extreme noob at all AJAX and javascript things, so the only thing I've tried so far is removing all superfluous code. It should load another letting the user select what bus stop in the county to choose, once it is done. Anyone able to see why it fails
anchor tag to submit a form to server not working   (266 Views)
RESOLVED i have a form with information in it, but to make it cleaner, i want to use an anchor tag to submit. the way i have it now is as follows: function submitter(formNum){ document.getElementById('form'+formNum).submit(); } send it There will be X number of these forms, so i was going to iterate through, and make em all form1, form2, form3, etc... and then pass in the number in the function which will submit. It doesnt seem to work. Alternate plans were do change the send it which also didnt seem to work. It needs to run on IE7, but that shouldnt be a problem. This post has been edited by fallenreaper: 20 October 2011 - 04:56 AM
question:how can i call a php file after submit button(in form)   (330 Views)
function validform(){ var x=document.forms["form3"]["name"].value; var y=document.forms["form3"]["f_name"].value; var z=document.forms["form3"]["email"].value; var atpos=z.indexOf("@"); var dotpos=z.lastIndexOf("."); if(x==null || x=='') { alert("your name is missing"); return false; } else if (y==null || y=='') { alert("your father name is missing"); return false; } else if (atpos
Change input value in form with jQuery   (110 Views)
Hi! I'm trying to help my user when they use my forms. The things I would love to do is to trim the value (strip leading and trailing spaces) and make first letter in every word capital. This is what I've came up with so far. HTML Javascript $(document).ready(function(){ var forename = $("#user_forenamne"); forename.blur(validateForename); function validateForename(){ var name = $("user_forename").val; //strip leading and trailing spaces name = $.trim(name) //change first letter in every word to uppercase name = Capital(name); //update input field whit new value $("#user_forename").val(name); } }); function Capital(value) { if (value != "") { var firstLetter = value.substring(0, 1).toUpperCase(); var restOfWord = value.substring(1, value.length).toLowerCase(); value = firstLetter + restOfWord; } When I try it nothing is happening. Does anyone understand why it isn't working or maybe have a better approach to sole this problem. Many thanks in advance Adam Nyberg This post has been edited by kingen: 15 June 2011 - 12:17 AM
My html form submit is not working after validation has completed   (144 Views)
My HTML with Javascript I had a problem with the form submittion.. where the javascript working fine for validation after completing validation my form submit is not processing to action specified in the form tag. Please help me out of this Here is the HTML Code 1. Position Applied for : --Select-- Helper Office Boy Sweeper LMV Driver HMV Driver Ex-70 Operator Ex-210 Operator Dozer Operator Roller Operator Fork Lift Operator Incinerator Operator Fitter Electrician Welder Sheet Welder Mechanic Auto Electrician Supervisor Foreman Cook Store Keeper Trainee Assistant Chief Executive Security Guard Head Guard Gardener Operator Chemist Accountant Officer Executive Painter Picker Turner Plant Operator Scavenger JCB Operator Tractor Driver Lab Attender Plumber Announcer Shift In charge Mason Weigh Bridge Operator Bobcat Operator Auto-Electrician System Administrator House Keeping Vehicle In charge Care Taker Carpenter Data Entry Operator Engineer Nurse Secretary ERP End User Shift Engineer Mechanic Welders ARCH / GAS / PLATE etc. Semi Skilled /Un - Skilled Workers 2. Full Name : 3. Father's / Husband's Name : 4. Present Address : 5. Permanent Address :   Contact Tel. No. Residence : STD Code Number   Mobile : 6. Email ID : 7. Date of Birth : (mm/dd/yyyy) 8. Age : 9. Gender : --Select-- Male Female 10. Marital Status : --Select-- Married Unmarried 11. Educational Qualifications : 12. Professional Qualifications : 13. Experience in years :   Details of experience : 14. Last Drawn Salary : 15. Slary Exepected : 16. Proof of Identify : --Select-- Pan Card Driving Licence Voter ID Ration Card Others 17. Preferred Location : --Select-- Hyderabad Bangalore Chennai Bhopal Any where in India Any where Others 18. Known References :     Reference1   Name : Designation : Company : Contact No. :           Reference2   Name : Designation : Company : Contact No. : 19. Achievements (Academic, sports, Cultural etc.) : 20. Languages Known : 21. Attach your Resume :       Note : Please upload your resume either in well formatted Ms-word (.doc) or text file(.txt).                       [b][size="5"]Javascript Code[/size][/b]function CalculateAge(birthday) { var re=/^(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d+$/; if (birthday.value != '') { if(re.test(birthday.value )) { birthdayDate = new Date(birthday.value); dateNow = new Date(); var years = dateNow.getFullYear() - birthdayDate.getFullYear(); var months=dateNow.getMonth()-birthdayDate.getMonth(); var days=dateNow.getDate()-birthdayDate.getDate(); if (isNaN(years)) { document.getElementById('strage').innerHTML = ''; alert("Input date is incorrect!"); return false; } else { document.getElementById('strage').innerHTML = years +' Years '; //document.getElementById('strage').innerHTML = years +' Years ' +months +' months '+days +' days'; } } else { alert("Date must be mm/dd/yyyy format"); return false; } } } function Check() { var valid = false; var position = document.getElementById("strposition").value; var fullname = document.getElementById("strfname").value; var fhname = document.getElementById("strfhname").value; var address = document.getElementById("straddress1").value; var prmntaddress = document.getElementById("straddress2").value; var stdcode = document.getElementById("strstdcode").value; var resiphone = document.getElementById("strresiphone").value; var mobile = document.getElementById("strmobile").value; var email = document.getElementById("stremail").value; var dob = document.getElementById("strdob").value; var education = document.getElementById("streducation").value; var professional = document.getElementById("strprofessional").value; var expyears = document.getElementById("strexpyears").value; var detailsexp = document.getElementById("strexperience").value; var lastdrawn = document.getElementById("strlastdrawn").value; var expected = document.getElementById("strexpected").value; var refname1 = document.getElementById("strrefname1").value; var refdesig1 = document.getElementById("strrefdesig1").value; var refcomp1 = document.getElementById("strrefcomp1").value; var refcontact1 = document.getElementById("strrefcontact1").value; var refname2 = document.getElementById("strrefname2").value; var refdesig2 = document.getElementById("strrefdesig2").value; var refcomp2 = document.getElementById("strrefcomp2").value; var refcontact2 = document.getElementById("strrefcontact2").value; var Achievements = document.getElementById("strAchievements").value; var languages = document.getElementById("strlanguages").value; var position_re = /^\d{3}$/; var fullname_re = /^[A-Z a-z]+\s*$/; var fhname_re = /^[A-Z a-z]+\s*$/; var address_re = /^[\w+[\,]\w+]|[\w]$/; var prmntaddress_re = /^[\w+[\,]\w+]*|[\w]*$/; var stdcode_re = /^\d{4,5}$/; var resiphone_re = /^\d{7,}$/; var mobile_re = /^\d{10}$/; var email_re = /^(\w+[\-\.])*\w+@(\w+\.)+[A-Za-z0-9]+$/; var dob_re=/^(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d+$/; var education_re = /^[A-Z a-z 0-9]+$/; var professional_re = /^[A-Z a-z 0-9]*$/; var expyears_re = /^[1-9]*$/; var detailsexp_re = /^[A-Z a-z]*$/; var lastdrawn_re = /^[0-9]*$/; var expected_re = /^[0-9]*$/; var refname1_re = /^[A-Z a-z]+$/; var refdesig1_re = /^[A-Z a-z]+$/; var refcomp1_re = /^[A-Z a-z]+$/; var refcontact1_re = /^[\d{10}]+$/; var refname2_re = /^[A-Z a-z]+$/; var refdesig2_re = /^[A-Z a-z]+$/; var refcomp2_re = /^[A-Z a-z]+$/; var refcontact2_re = /^[\d{10}]+$/; var Achievements_re = /^[A-Z a-z 0-9]*$/; var languages_re = /^[A-Z a-z]*[\,]*[A-Z a-z]*$/; if(document.form1.strposition.selectedIndex != 0 ) { if (fullname_re.test(fullname)) { if (fhname_re.test(fhname)) { if (address_re.test(address)) { if (prmntaddress_re.test(prmntaddress)) { if((mobile_re.test(mobile)) || ((stdcode_re.test(stdcode)) & (resiphone_re.test(resiphone)))) { if (email_re.test(email)) { if(dob_re.test(dob)) { if(document.form1.strgender.selectedIndex != 0 ) { if(document.form1.strmaritalstatus.selectedIndex != 0 ) { if (education_re.test(education)) { if (professional_re.test(professional)) { if (expyears_re.test(expyears)) { if (detailsexp_re.test(detailsexp)) { if (lastdrawn_re.test(lastdrawn)) { if (expected_re.test(expected)) { if(document.form1.strlocation.selectedIndex != 0 ) { if(((refname1_re .test(refname1)) & (refdesig1_re.test(refdesig1)) & (refcomp1_re.test(refcomp1)) & (refcontact1_re.test(refcontact1))) || ((refname2_re .test(refname2)) & (refdesig2_re.test(refdesig2)) & (refcomp2_re.test(refcomp2)) & (refcontact2_re.test(refcontact2)))) { if (Achievements_re.test(Achievements)) { if(languages_re.test(languages)) { //var scriptPath = ""; //document.getElementById("form1").setAttribute("action", scriptPath); //document.form1.action = "Kvrjobfile.php"; //document.forms.form1[0].action = "Kvrjobfile.php"; //document.form1.action['Kvrjobfile.php']; //document.getElementById('form1').action = ""; } else alert("Please enter language in alphabets"); } else alert("Please enter achievements in alphanumeric"); } else alert("Please enter Known Refernce:name,designation must be in alphabets and contact number in numeric"); } else alert("Please select Preferred location"); } else alert("Plaese enter last drawn salary must be numeric"); } else alert("Plaese enter last drawn salary must be numeric"); } else alert("Plaese enter Details of exp must be alphabets"); } else alert("Please enter experience greater than 0"); } else alert("Please enter professional qualification in alphanumeric"); } else alert("Please enter educational qualification must be in alphanumeric"); } else alert("Please select Marital Status"); } else alert("Please select gender"); } else alert("please enter date of birth in mm/dd/year format"); } else alert("Please enter valid email id"); } else alert("Please enter contact number"); } else alert("Please enter Permanent address in alphanumeric"); } else alert("Please enter Present address in alphanumeric"); } else alert("Please enter Father/Husband name must be alphabets only"); } else alert("Please enter your fullname must be alphabets only"); } else alert("Please select Position applied for job"); return valid; } Mod Edit: !!!
Javascript date format strInput.   (84 Views)
I was just wondering how to do this, (format strInput 01/01/2011 to January 1, 2011), just put me on the right track please. This is what I have right now. Doc Comp HTML Form     Date:       function formatDate() { var strInput = document.all.Date.value; var strOutput = ""; alert(strInput); //format strInput 01/01/2011 to January 1, 2011 document.all.Date.value = strOutput }
How to reset forms after using post of jQuery?   (180 Views)
I have created pages to comping some content and adding it into db. Here they are composing.php Composing news function reset_form() { document.getElementById("title").reset(); } $(document).ready(function(e) { // ready method make funtion available after the document has been loaded $("#submit").click(function(){ if($("#title").val().length == 0 || $("#category").val().length == 0 || $("#summary").val().length == 0 || $("#content").val().length == 0) { alert("Please fill into every blank!"); } // end if else { $.post("adding.php",{title: $("#title").val(), category: $("#category").val(), summary: $("#summary").val(),content: $("#content").val()}, function(data){ // post method is used to perform an AJAX HTTP POST request //alert("ok"); }); // end $.post } // end else }); // end $("#submit) }); // end $(document) #submit{ padding: 5 5 5 5; border-radius: 5px; text-align:center; display:inline; background-image: linear-gradient(bottom, rgb(81,151,239) 15%, rgb(114,182,255) 58%, rgb(149,219,255) 79%); background-image: -o-linear-gradient(bottom, rgb(81,151,239) 15%, rgb(114,182,255) 58%, rgb(149,219,255) 79%); background-image: -moz-linear-gradient(bottom, rgb(81,151,239) 15%, rgb(114,182,255) 58%, rgb(149,219,255) 79%); background-image: -webkit-linear-gradient(bottom, rgb(81,151,239) 15%, rgb(114,182,255) 58%, rgb(149,219,255) 79%); background-image: -ms-linear-gradient(bottom, rgb(81,151,239) 15%, rgb(114,182,255) 58%, rgb(149,219,255) 79%); background-image: -webkit-gradient( linear, left bottom, left top, color-stop(0.15, rgb(81,151,239)), color-stop(0.58, rgb(114,182,255)), color-stop(0.79, rgb(149,219,255)) ); } #reset{ padding: 5 5 5 5; border-radius: 5px; text-align:center; display:inline; background-image: linear-gradient(bottom, rgb(167,12,21) 12%, rgb(201,39,49) 56%, rgb(242,67,79) 78%); background-image: -o-linear-gradient(bottom, rgb(167,12,21) 12%, rgb(201,39,49) 56%, rgb(242,67,79) 78%); background-image: -moz-linear-gradient(bottom, rgb(167,12,21) 12%, rgb(201,39,49) 56%, rgb(242,67,79) 78%); background-image: -webkit-linear-gradient(bottom, rgb(167,12,21) 12%, rgb(201,39,49) 56%, rgb(242,67,79) 78%); background-image: -ms-linear-gradient(bottom, rgb(167,12,21) 12%, rgb(201,39,49) 56%, rgb(242,67,79) 78%); background-image: -webkit-gradient( linear, left bottom, left top, color-stop(0.12, rgb(167,12,21)), color-stop(0.56, rgb(201,39,49)), color-stop(0.78, rgb(242,67,79)) ); } Composing Title: Category: Summary: Content: Submit Reset adding.php