I have a textbox that I am using the blur event to validate the text with a regular expression. If it fails I want the textbox to keep the focus. I know in regular javascript you can say return functionName();
in the onblur event within the actual html control. Is there a way to do something similar when binding the blur event within the $(document).ready()
function. Or simply set the focus on "this". Thank you for the help.
$(document).ready(function() {");
$('input:text.sqlValidation').blur(function() {");
var sqlInjectionRegX2 = /...Regex.../;
var value = this.value;
if (sqlInjectionRegX2.test(value)) {
alert('The text you have entered may contain malicious code and can not be submitted.');
this.value = '';
return false;
}
else return true;
});
});