azhao Posted May 4, 2009 Share Posted May 4, 2009 Hi all, We had a developer who left our company a while ago. The following is a simplified Javascript snippet he wrote: var reg_exp = /^[\000-\177]*$/; if(reg_exp.test(document.getElementById('some_field').value == false) { alert('Invalid format'); } The purpose of the code is to validate Amazon product's description which the spec says "Type 1 High ASCII characters (® , ©, tm , etc.) or other special characters are not allowed" I assume jQuery is used here. What does that regular express match? What exactly are "Type 1 High ASCII characters? I did some researches on ASCII characters but couldn't find a definitive answer. Please advise. Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 4, 2009 Share Posted May 4, 2009 Well if ASCII, then they're in Octal format. It's just pretty much a whole array of keys that someone can type into a form. I don't see the point of it because the Regex test would almost always be true. Also, your test method is missing a parenthesis. if(reg_exp.test(document.getElementById('some_field').value) == false) { Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.