Reputation: 855
I know the selector used for name is $('input[name=xyz]')
but what if I have a condition ex.
if (input.is("[name=listItem,GrdFromDateTime,GrdToDateTime,GrdRemarks]"))
how can I achieve this?
Thanks in Advance :)
Upvotes: 4
Views: 71
Reputation: 68393
try this
var validValues = "listItem,GrdFromDateTime,GrdToDateTime,GrdRemarks";
if ( validValues.split(",").indexOf( input.attr("name") !== -1 )
I thought you were wanted to check if all complete string is matching
Upvotes: 2
Reputation: 87203
Keep the names in an array and check if the current input name
attribute is in the array.
var names = ["listItem", "GrdFromDateTime", "GrdToDateTime", "GrdRemarks"];
if(names.indexOf(input.attr('name')) !== -1) {
Upvotes: 8