views:

312

answers:

2

Hi, I'm using jquery validation with asp.net. The problem is, I have the search button and the comments button in the same form. When the users want to write a comment, the validation works perfect, but when the users want to make a search in the page, the required fields of the comments dosn't allow them.

So the question is how can I disable the validation for an specific button.

Thanks roncansan

A: 

Move the validation to the click event of the button and use preventDefault() if it fails validation.

$("#yourButtonId").click( function(event){
  if (formIsInvalidForSubmission)
     event.preventDefault();      
});
altCognito
A: 

Thanks,

I do something like this

//$(document).ready(function() { $("#send").click(function() { var validator = $("#aspnetForm").validate({ rules: { ctl00$MainContent$TBMail: { required: true, email: true }, ect.. but now nothing gets validated.

Any insights.

Thanks

related questions