Click here to Skip to main content
15,886,799 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a form contain textbox and submit and cancel button. I don't the modal do jquery validation on focus out of textbox. thats why when user go for clicking on close button it do validation.

How to prevent that.
I don't want validation on close button
C#
<form>
<input type="text" value="userId"/>
<input type="submit" value="Save"/>
<input type="button" value="Close"/>
</form>


form is having jquery validation
Posted
Updated 13-Oct-14 1:09am
v3
Comments
[no name] 13-Oct-14 6:26am    
Please post your code here. So that we can get to know the issue and what you have done.
Thanks.
hemant malpote 13-Oct-14 6:50am    
Please check the updated question
[no name] 13-Oct-14 7:03am    
You must have added validation on the model, please check there.
[no name] 13-Oct-14 7:03am    
and also give your script code. Here there seems no issues.
hemant malpote 13-Oct-14 7:06am    
validation i s on form. modal automatically call validator on focus out of textbox

1 solution

Please check here[^]
Check this blog and see, else comment your queries.

Fiddle[^]

I have worked on this fiddle that will check validation without the focus event.
Thanks
 
Share this answer
 
v2
Comments
hemant malpote 13-Oct-14 9:12am    
This solution will work, but just one problem. When i click on cancel button , first focus out event fire and it checks the validation. If i stopped there like your solution it will stop validation even i click some where else. Is it possible on focus out event to check whether some other event is in queue
[no name] 13-Oct-14 9:22am    
yes in the blog
there is a settings where the events are set to true/false
you can use that
hemant malpote 13-Oct-14 9:29am    
$('.modal-form').on('focusout', function (e) {

});
i want to know here whether close button click will be called after this event. There are 2 case : 1 :If somebody type something in textbox and click some where, focus out will fire and validation work i.e fine. 2: If somebody type something in textbox and click on cancel directly focus out will called it will do validation if not validate it does not allow to trigger close button click event
So i want to do this in above method
[no name] 13-Oct-14 9:53am    
Please check the updated solution where i have given a fiddle, check and comment if any issue.
Thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900