设置光标位置 [英] set cursor location

查看:85
本文介绍了设置光标位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每次打开页面时如何设置光标位置当输入字段中的光标变为自动并且点击输入字段的提交长度时会发生变化

解决方案

hi .. 。


你可以使用的文件:

展开 | 选择 | 换行 | 行号


< blockquote>嗨gits

i需要chak onclick提交按钮节点id的长度帮助这个

Regard

sanjeev jha


这是一个简单的例子......根据您的需要进行调整:


[HTML]< html>

< script type =" text / javascript">

function check_form(){

var n = document.getElementById(''my_id'');

var val = n.value.length> 1;


if(!val){

alert(''需要多一个字符'');

}


n.style.backgroundColor = val? ''white'':''#FFCC99'';


返回val;

}

< / script>

< body>

< form name =" my_form" onsubmit =" return check_form();">

< input type =" text" id =" my_id" />

< input type =" submit" value =" Submit" />

< / form>

< / body>

< / html>

[/ HTML]

亲切的问候


how can set cursor location everytime when page is open cursor goes to auto in input field and chake when click on submit lenth of input field

解决方案

hi ...

onload of the document you may use:

Expand|Select|Wrap|Line Numbers


Hi gits
i have need to chak onclick submit button the lenth of node id help in this
Regard
sanjeev jha


here is a simple example ... adapt it to your needs:

[HTML]<html>
<script type="text/javascript">
function check_form() {
var n = document.getElementById(''my_id'');
var val = n.value.length > 1;

if (!val) {
alert(''more then one char required'');
}

n.style.backgroundColor = val ? ''white'' : ''#FFCC99'';

return val;
}
</script>
<body>
<form name="my_form" onsubmit="return check_form();">
<input type="text" id="my_id"/>
<input type="submit" value="Submit"/>
</form>
</body>
</html>
[/HTML]
kind regards


这篇关于设置光标位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆