Errors when entering incomplete regex into filter?
Errors when entering incomplete regex into filter?
bchurchill
Posts: 3Questions: 0Answers: 0
Hi all,
I've just got regular expression filtering setup on individual columns with smart filtering turned off. However, when the user starts typing in a regular expression but is not yet finished (like "[23") javascript errors come up. To the user the functionality works; when they finish typing in their expression ("[234]<") it filters properly. However I would like to eliminate the associated error. It comes from the minimized jquery file. The errors are regarding the unfinished regular expression, e.g. "trailing \ in regular expression" or "unterminated character class".
If you want to see my code/exactly what's happening, you can visit http://dana.ucc.nau.edu/~brc77. You can reproduce the errors in Firefox 3.6 by clicking the "Use regular expression filtering" check and then typing a '[' into any of the filter boxes. (and if you have suggestions on making the checkbox more responsive, that would be appreciated too...).
Thanks
Berkeley
I've just got regular expression filtering setup on individual columns with smart filtering turned off. However, when the user starts typing in a regular expression but is not yet finished (like "[23") javascript errors come up. To the user the functionality works; when they finish typing in their expression ("[234]<") it filters properly. However I would like to eliminate the associated error. It comes from the minimized jquery file. The errors are regarding the unfinished regular expression, e.g. "trailing \ in regular expression" or "unterminated character class".
If you want to see my code/exactly what's happening, you can visit http://dana.ucc.nau.edu/~brc77. You can reproduce the errors in Firefox 3.6 by clicking the "Use regular expression filtering" check and then typing a '[' into any of the filter boxes. (and if you have suggestions on making the checkbox more responsive, that would be appreciated too...).
Thanks
Berkeley
This discussion has been closed.
Replies
[code]
try {
var re = new RegExp(textbox_value); // will throw exception?
oTable.fnFilter(textbox_value);
}
catch (err) {
// ignore.. just trapping error and avoiding calling fnFilter.
}
[/code]
but if the user doesn't see it, does the error really happen? *omm*
Question though: is the default javascript RegExp object the same one that jQuery/datatables uses for regular expressions? Or does jQuery do something custom? If it is custom, is there the chance that a regular expression will be valid for one implementation but not the other, causing problems?