日期:2014-05-16 浏览次数:20375 次
if(obj.value==""){
obj.focus();
return false;
}
<script language="javascript">
function getSelectPos(obj){
var esrc = document.getElementById(obj);
if(esrc==null){
esrc=event.srcElement;
}
var rtextRange =esrc.createTextRange();
rtextRange.moveStart('character',esrc.value.length);
rtextRange.collapse(true);
rtextRange.select();
}
</script>
function getSelectPos(obj){
var esrc = document.getElementById(obj);
if(esrc==null){
esrc=event.srcElement;
}
//ie
if(typeof esrc.createTextRange!=="undefined"){
var rtextRange =esrc.createTextRange();
rtextRange.moveStart('character',esrc.value.length);
rtextRange.collapse(true);
rtextRange.select();
}
//other
else if(typeof esrc.selectionStart!=="undefined")
{
esrc.selectionStart=esrc.value.length;
esrc.focus();
}
//not suppert
else{
alert("not support");
}
}
<script type="text/javascript">
function test(obj) {
if (typeof obj == 'string') obj = document.getElementById(obj);
obj.focus();
if (obj.createTextRange) {
var rtextRange = obj.createTextRange();
rtextRange.moveStart('character', obj.value.length);
rtextRange.collapse(true);
rtextRange.select();
}
else if&