jquery disable rule validation on a single field
Posted
by shake
on Stack Overflow
See other posts from Stack Overflow
or by shake
Published on 2010-05-17T22:44:29Z
Indexed on
2010/05/17
22:50 UTC
Read the original article
Hit count: 228
jquery-validate
I am using mvc to create forms that are generated at runtime. For validation, I am trying my hand at the jquery validation library which is very convenient to use. I have the validation expression of each field in the cdata attribute of the tag
<input type="text" name="xyz" id="xyz" class="defaultTextBox"
cdata="{validate:{required:true, decimal:true, messages:
{required:'Please enter an decimal value',
decimal:'Please enter a valid decimal'}}}">
This works beautifully. Now one more requirement I have is that some fields are being shown and hidden according to the logic on the page and I need to disable the validation on the hidden fields such that they do not interfere with the form submission. Just toggling the required:true to false and back to true should be enough. Only i do not know how.
Anyone has any experience with that?
© Stack Overflow or respective owner