Your code is alot better than mine and the use of test instead of match is better too. However I still have the same problem, even with your code with Firefox after 16 characters even typed slowley, Firefox becomes slow and after 20-25 characters it even blocks... Is this a bug with firefox or with my code ? How can I fix this problem ?
Is it my RegExp ? I can't see how it could be the code as yours is very simple Rik Lomas wrote: > > > I've simplified your code for you and sped up your testing by using > the regular expression "test()" method > > $(document).ready(function(){ > $('input#domain').keyup(function(){ > var domain = $(this).val(); > var reg = /^([a-z0-9]+(\-?\.?[a-z0-9]*)){2,63}\.([a-z]){2,4}$/i ; > if (reg.test(domain)) { > $("#ok").html("Correct format ..."); > } else { > $("#ok").html("Wrong format ...</p>"); > } > }); > }); > > > > 2008/11/19 Jsbeginner <[EMAIL PROTECTED]>: >> >> >> Hello, this is my first topic here, so I hope that I'm doing the right. >> I've >> done a search on google and on this forum without finding anyone with the >> same problem as me, but maybe I'm not looking for the right keywords. >> >> Here is my problem : I've created a very simple script that checks if a >> domain is in a valid format or not, however with Firefox 3 it does not >> like >> domains that are more than 20 characters long and firefox slows down and >> then completly blocks. >> >> Here is my code : >> >> test.js : >> 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"); >> }); >> >> >> test.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> >> >> -- >> View this message in context: >> http://www.nabble.com/Firefox-problems-%28-with-input-reg.-exp.-verification%29.-tp20580852s27240p20580852.html >> Sent from the jQuery General Discussion mailing list archive at >> Nabble.com. >> >> > > > > -- > Rik Lomas > http://rikrikrik.com > > -- View this message in context: http://www.nabble.com/Firefox-problems-%28-with-input-reg.-exp.-verification%29.-tp20580852s27240p20598552.html Sent from the jQuery General Discussion mailing list archive at Nabble.com.