The only opportunity to identify the error in a given string I see at the moment Is the following: You have to break up your regex and loop over the string.
Since your regex is fairly easy, you can start with ^[A-Z]
to check if the first Symbol mathces a letter.
After that you go like this:
function check(string){
var error = false,
position = -1;
loop : for(i=1;i<string.length;i++){
var res = string.substring(i,i+1).match(/[A-Za-z]/);
if(!res){
position = i+1;
error = true;
break loop;
}
}
return {'error':error,'position':position};
}
var check = check("aasfcd");
if (check.error){
document.write("Error occured on position: "+check.position);
}else{
document.write("Your string is okay");
}
See example fiddle