This is a bug related to the code I have made.
I was making a Text Length validation field, came up with some kind of working code. However something that I am doing here is causing the Text cursor to move to the left every time you type, meaning that your typed text comes out backwards or in a mess.
What is happening below that could be causing this? I'd imagine probably the splice?
JSFiddle and jQuery below
$(function(){
var charLimit = 10;
$('.input').keypress(function(e){
if (e.which > 0){
var string = $(this).text().split("");
for(i=0;i<charLimit;i++){
if(string[i] !== undefined){
string.splice((charLimit-1),0,"<span class='error'>");
string.push("</span>");
}
}
$(this).html(string.join(""));
}
});
});