如何由首字母来确定文本框的输入长度? 如何由首字母来确定文本框的输入长度?例如:首字母是A‘只能输入5位 首字母是B‘只能输入6位 首字母是C‘只能输入7位 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 onchange时候或者onfocus的时候就获取他限制 <input type="text" maxlength="3" onfocus="getMaxLength(this)"><script>function getMaxLength(input){ alert("length : " + input.getAttribute("maxlength"));}</script> <script laguage="javascript">function test(obj){ firstIndex = obj.substr(0,1); maxLeng = firstIndex.charCodeAt()-60; if(obj.length > maxLeng){ alert('以'+firstIndex+'开头,只能输入'+maxLeng+'位'); document.getElementById('test').value = obj.substr(0,maxLeng); }}</script><input type="text" onkeyup="test(this.value)" id='test'> 如果要在PHP页面处理,可通AJAX,用正则来判断 mysql备份问题 php连接mssql2000 如何将较长的文本内容多行显示? 它的静态页面修改字体大小是怎么实现的? 高分求用PHP操作EXCLE的例子 如何设置sendmai_from才能发送邮件啊,要发送邮件该怎么设置?? form 里提交表单,窗口的问题 关于多表查询的问题 奇怪,在php3运行的好好的程序怎么到php4有问题了? Access数据库中备注字段类型 mysql应该用什么字段类型来作相应的替代? 看看大家对jquery的看法!!!!! 是数据库没有配置好吗?
<script>
function getMaxLength(input){
alert("length : " + input.getAttribute("maxlength"));
}
</script>
function test(obj)
{
firstIndex = obj.substr(0,1);
maxLeng = firstIndex.charCodeAt()-60;
if(obj.length > maxLeng){
alert('以'+firstIndex+'开头,只能输入'+maxLeng+'位');
document.getElementById('test').value = obj.substr(0,maxLeng);
}
}
</script><input type="text" onkeyup="test(this.value)" id='test'>