0

我想在空格验证后将焦点放在文本的最后一个字符上。焦点不会落在最后一个元素上。请查看代码并向我提出任何更改建议。

var pattern=/^\s|\s$/;
var textentered=document.textentered.text.value;
if(textentered.match(pattern))
{
  alert("Spaces are not allowed");
  textentered.focus();
  return false;
}

谢谢

4

1 回答 1

1

我想你想要

document.textentered.text.focus();

目前,您正试图专注于价值,而不是元素。

于 2013-03-07T14:49:38.173 回答