Alright ... here is some code that I think will work for you or at least start.
Basically, for regular expression you need to find all over 19 characters:
var extra = content.match(/.{19}(.*)/)[1];
So, I put together a sample document on how you can use this.
Take a look at DEMO .
Here is the Javascript that I use (I use jQuery for locators here, but it can be easily changed to use direct Javascript ... I just prefer jQuery for such things) ...
$(document).ready(function() { $('#myDiv').keyup(function() { var content = $('#myDiv').html(); var extra = content.match(/.{19}(.*)/)[1]; $('#extra').html(extra); var newContent = content.replace(extra, "<span class='highlight'>" + extra + "</span>"); $('#sample').html(newContent); }); });
Basically, I have three DIV settings. One for you to enter your text. One to show which characters exceed the 19-digit limit. And one to show how you can highlight extra characters.
My html tags are not checked in my code example, since there are too many of them to process them ... but should give you an excellent starting point as to how this might work.
NOTE : you can view the full code that I wrote using this link: http://jsbin.com/OnAxULu/1/edit
Charlie74
source share