Jquery validation plug in issue with if/else. Jake help
Hi;
I use Jquery validation class .
Since I generate text boxes based on user's choice, I need to make the validation only happen when the user has checked a box. So I change the origial code to what I thought should work but it doesn't.
This is the part I added: if ($('input.txt_firstname').is(':checked'))
Please advice. Thanks
This is the orignal code:
- $().ready(function ()
{
// validate signup form on keyup and submit
$("#template_form").validate(
{
rules:
{
firstName: "required",
},
messages:
{
firstName: "Please enter your firstname",
}
});
});
This is what I thought would work:
- $().ready(function ()
{
// validate signup form on keyup and submit
$("#template_form").validate(
{
rules:
{
if ($('input.txt_firstname').is(':checked'))
{
firstName: "required",
}
},
messages:
{
firstName: "Please enter your firstname",
}
});
});