« May 2011 | Main | July 2011 »
June 13, 2011
IE 7 Zero Length Regex Matches
An IE lastIndex Bug with Zero-Length Regex Matches
Posted by pj at 05:19 PM | Comments (0)
Detect curly quotes with JavaScript
function check_quotes(){
var s = '';
var regex = /\W/g;
var m = null;
var text = null;
var code = null;
['asset_name','body','summary'].each(function(da_id){
text = document.getElementById(da_id).value;
m = regex.exec(text);
if(da_id == 'asset_name'){ da_id = 'title'; }
var count = 0;
while(m){
code = m[0].charCodeAt(0);
if(code > 8200){
s = s + "\n<li> Found " + m + " in " + da_id.split('_').join(' ') + " text</li>";
count++;
}
count++;
m = regex.exec(text);
}
});
if(s != ''){ poppy('Illegal characters found in your title or description:<br/><br/><ul>' + s + '</ul><br/>Delete and then re-type quotes and long dashes in the editor above before proceeding. Please try and avoid cutting and pasting from Word.'); return true; }
return false;
}
Posted by pj at 04:23 PM | Comments (0)