I wish I could solve this on my own, but I never understood regular expressions. They seem so powerful. I wanted to ask where is the best resource for learning javascript reg ex, but this was subjective, and I did not want my question to close. I have a web form text field, when it matters, this value must be an integer from 1 to 999999. I already use the jquery numeric widget to include only numbers, all other keystrokes are rejected, there is an onBlur implementation, what if any regular expression is not matched, a callback will be called ... This is that code ...
$.fn.numeric.blur = function()
{
var decimal = $.data(this, "numeric.decimal");
var callback = $.data(this, "numeric.callback");
var val = $(this).val();
if(val != "")
{
var re = new RegExp("^\\d+$|\\d*" + decimal + "\\d+");
if(!re.exec(val))
{
callback.apply(this);
}
}
}
, , val 1 999999? . , , javascript regex? . !
Cheers,
~ ck -