Jquery Submit Validation Not Posting
Hello all,
I've customized my form to validated the required fields but it doesn't submit even though all fields are filled in correctly. From my understanding, the jquery.validate.min.js blocks it from being submitted. Does anyone know why my form doesn't submit?
The code is below:
- <head>
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
- <script src="http://jqueryvalidation.org/files/dist/jquery.validate.min.js"></script>
- <script src="http://jqueryvalidation.org/files/dist/additional-methods.min.js"></script>
- <link rel="stylesheet" href="http://jqueryvalidation.org/files/demo/site-demos.css">
- </head>
- <div>
- <form id="myform">
- <label for="fname">First Name *: </label>
- <input id="fname" name="fname">
- <br/>
- <label for="lname">Last Name *: </label>
- <input id="lname" name="lname">
- <br/>
- <label for="email">Email *: </label>
- <input id="email" name="email">
- <br/>
- <label for="jtitle">Job Title *: </label>
- <input id="jtitle" name="jtitle">
- <br/>
- <label for="orgname">Organization *: </label>
- <input id="orgname" name="orgname">
- <br/>
- <label for="orgname">Describe Yourself *: </label>
- <input id="desyourself" name="desyourself" type="hidden" value="123">
- <select id="desyourself" name="desyourself">
- <option value="">
- Choose One... </option>
- <option value="124">
- Customer
- </option>
- <option value="125">
- Partner
- </option>
- <option value="126">
- Prospect
- </option>
- <option value="127">
- Other
- </option>
- <option value="128">
- Misc.
- </option>
- </select>
- <br/>
- <input type="submit" value="Validate!">
- </form>
- </div>
- <script>
- // avoids form submit
- jQuery.validator.setDefaults({
- debug: true,
- success: "valid"
- });
- $.validator.methods.email = function( value, element ) {
- return this.optional( element ) || /^([\w-\.]+@(?!gmail.com)(?!yahoo.com)(?!hotmail.com)([\w-]+\.)+[\w-]{2,4})?$/.test( value );
- }
- $( "#myform" ).validate({
- rules: {
- fname: {
- required: true,
- minlength: 1,
- maxlength: 30,
- lettersonly: true
- },
- lname: {
- required: true,
- minlength: 1,
- maxlength: 30,
- lettersonly: true
- },
- email: {
- required: true,
- email: true
- },
- jtitle: {
- required: true,
- minlength: 1,
- maxlength: 30
- },
- orgname: {
- required: true,
- minlength: 1,
- maxlength: 30
- },
- desyourself: {
- required: true,
- }
- }
- });
- </script>