Note that there are some explanatory texts on larger screens.

plurals
  1. POHelp with jQuery validation
    primarykey
    data
    text
    <p>I'm having a problem coding for a form validation. I'll post the code below. Basically i want the form to submit if cboAction is on another selection.</p> <p>cboAction has three values, <strong>[Select]</strong>, <strong>Insert</strong> and <strong>Search</strong>. So if Insert is selected in the combobox then the form should validate using jquery else if Search is selected then the form should get submitted. I tried putting an if statement in there but it didn't work. :(</p> <p>Btw the form validation works, its just that i can't get the above working. Hope to hear from someone.</p> <p>Thanks</p> <pre><code>jQuery.validator.addMethod( "selectOption", function(value, element) { if(element.value == "nothing") { return false; } else { return true; } }, "Please select an option." ); $(document).ready(function() { $("#authorForm").validate({ rules: { cboAction: {selectOption:false} txtName: {required:true}, txtStreet: {required:true} txtTown: {required:true}, cboState: {selectOption:true}, txtPostcode: {required:true}, txtMobile: {required:true}, txtEmail: {required:true, email:true} }, messages: { cboAction: "Please select an action" txtName: {required: "Author's Name is a required field"}, txtStreet: {required: "Street is a required field"} txtTown: "Town is a required field", cboState: "Please select a state", txtPostcode: "Postcode is a required field", txtMobile: { required: "Mobile is a required field", email: "Please enter a valid email adress" } } }); }); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload