I have a list with checkboxes on a page. Whenever an item is selected it should be compared with a CSV string, stored in a hidden input field. The string looks likes 13,14,19`.
I need to show an alert box if the value of the selected checkbox matches with any of value that exists in my CSV string.
My js function is
$(document).ready(function () {
$('#<%=chkboxListReportReq.ClientID %>').click(function () {
$('#<%=chkboxListReportReq.ClientID %> input:checked').each(function () {
alert($(this).closest('span').attr('data-value'));
//alert($(this).next('label').text());
});
});
});
This is what I’ve tried so far…
Based on your last comment there exsist more than one way. The best way is to using
search(). Although is comes from plain Javascript, you can use it with strings stored in jquery variables.To
search()itself:This method uses the Regular Expression object, as you can see like follows:
For an overview about the syntax of regular expressions you should look up at the Internet or here. I’m defnetly not an expert for
req expr. The following link gives you some information, though I think there exists better ones.