I'd like to place the focus on the last character of the text after the whitespace validation. The focus doesn't end up on the last element. Please look into the code and suggest any changes to me.
var pattern=/^\s|\s$/;
var textentered=document.textentered.text.value;
if(textentered.match(pattern))
{
alert("Spaces are not allowed");
textentered.focus();
return false;
}
Thanks