I didnt write the code below but ive added an if to it, to check for a value called starts, if starts is set to 1, I only want to return results that start with the value, i tried searching RegEx exp and swapped out the 'i' for a 'a' or '\A' but neither work, what character do i need in there for a starts with?
Thanks
function searchTable(inputVal, tablename,starts) {
var table = $(tablename);
table.find('tr:not(.header)').each(function (index, row) {
var allCells = $(row).find('td');
if (allCells.length > 0) {
var found = false;
allCells.each(function (index, td) {
if (starts = 1) {
var regExp = new RegExp(inputVal, 'i');
} else {
var regExp = new RegExp(inputVal, 'i');
}
if (regExp.test($(td).text())) {
found = true;
return false;
}
});
if (found == true) $(row).show().removeClass('exclude'); else $(row).hide().addClass('exclude');
}
});
}