Hey All, I have a form that I need 2 inputs to be mandatory before the mail gets sent. (the name and email)
Here is the form code.
And here is the JS that I am using with it.Code:<form id="FormTB" action=""> <input type="hidden" id="Form_ID" name="Form_ID" value="<?php echo $eid; ?>" /> <center><strong>Request a Quote</strong></center><br /> <table width="100%"> <tr> <td width="30%">*Your Name:</td><td width="20%"> </td><td width="50%"><input type="text" id="Form_Name" name="Form_Name" /></td> </tr> <tr> <td width="30%">Company Name:</td><td width="20%"> </td><td width="50%"><input type="text" id="Form_Company" name="Form_Company" /></td> </tr> <tr> <td>*Your E-Mail:</td><td> </td><td><input type="text" id="Form_Email" name="Form_Email" /></td> </tr> <tr> <td width="30%">*Phone Number:</td><td width="20%"> </td><td width="50%"><input type="text" id="Form_Number" name="Form_Number" /></td> </tr> <tr><td colspan="3"> </td></tr> <tr> <td width="100%" align="center" colspan="3"> <input type="button" class="button" name="Form_Submit" value="Request Quote" /> </td> </tr> <tr><td colspan="3"> </td></tr> <tr> <td width="100%"> <b><?php echo $name; ?></b><br /> <b>Manufacturer:</b> #<?php echo $manu;?><br /> <b>Model#:</b> <?php echo $model;?><br /> <b>Category:</b> <?php echo $Category;?><br /> </td> </tr> </table> </form>
I know you have to add something likeCode:<script language="javascript" type="text/javascript"> $(function() { $(".button").click(function() { var name = $("#Form_Name").val(); var email = $("#Form_Email").val(); var eid = $("#Form_ID").val(); var company = $("#Form_Company").val(); var number = $("#Form_Number").val(); var dataString = 'name='+ name + '&email=' + email + '&eid=' + eid + '&Company=' + company + '&Number=' + number; //alert (dataString);return false; $.ajax({ type: "POST", url: "AJAX_Quote.php", data: dataString, success: function() { tb_remove(); setTimeout("Thanks()", 450); } }); }); }); function Thanks() { tb_show('Thank You', '#TB_inline?width=400&height=400&inlineId=TBThanks&modal=false', false); } jQuery.noConflict(); function clearText(field){ if (field.defaultValue == field.value) field.value = ''; else if (field.value == '') field.value = field.defaultValue; } </script>
But not quite sure how to do it. Can I just add that code to my existing JS or do I have to completely redo it?Code:/* validate function returns true if "ok" false if "bad" */ validate = function(){ /* Check if it is blank */ if (document.getElementById('Form_Name').value = ''){ alert('You must enter a First Name!'); return false; } return true; }
Any help would be appreciated.
Thanks



Reply With Quote





Bookmarks