Simple RegExp check slow on Firefox
Hello, I'm having problems with a simple script that makes Firefox slow down then block when a user enters more than 20 characters into in input box...
Here's the Javascript test.js file :
-
function domchk() {
var domain = $("input#domain").val();
var reg = /^([a-z0-9]+(\-?\.?[a-z0-9]*)){2,63}\.([a-z]){2,4}$/i ;
if (domain.match(reg)) {
$("#ok").html("Correct format ...");
} else {
$("#ok").html("Wrong format ...</p>");
}
}
function simple_chk(target_items){
$(target_items).each(function(){
$(this).keyup(function(){
domchk();
});
});
}
$(document).ready(function(){
simple_chk("input");
});
And here's the HTML :
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Test page</title>
<script type="text/javascript" src="jquery-1.2.6.min.js"></script>
<script type="text/javascript" src="test.js"></script>
</head>
<body>
<h1> Javascript domain check ...</h1>
<form>
<p>
<input id="domain" type="text" /></p>
<p id="ok">Not changed yet...</p>
</form>
</body>
</html>
This code works fine on all browsers that I have tried so far except with firefox 3 but I've not been able to find what makes firefox block when the input value exceeds around 20 characters ... ?
Thanks in advance
