欢迎来到亿搜云建站平台,全网营销云系统加盟中心!

海量企业网站模板 · 任您选择

美出特色,精出品质,一切为了企业更好的营销

隐藏侧栏
Beta
转载

JS判断输入框不能为空代码

       对话框和灯箱     2016-02-16     eycms     86     0    

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 

<html xmlns="http://www.w.org/1999/xhtml"> 

<head> 

<meta http-equiv="Content-Type" content="text/html;charset=gb2312" /> 

<title>JS判断输入框不能为空</title> 

<script language="Javascript"> 

<!-- 

function checkChinese() 

{ var isnumandchar; 

var StrForCheck=form_key.keywords.value; 

var c; 

c = StrForCheck.charAt(0); 

while((c ==" "||c ==" ") && StrForCheck.length > 0) 

StrForCheck = StrForCheck.slice(1); 

c = StrForCheck.charAt(0); 

c = StrForCheck.charAt(StrForCheck.length -1); 

while((c ==" "||c ==" ") && StrForCheck.length > 0) 

StrForCheck = StrForCheck.substring(0,StrForCheck.length-1); 

c = StrForCheck.charAt(StrForCheck.length -1); 

form_key.keywords.value = StrForCheck;//如果没有值,继续 

if (StrForCheck.length==0 || StrForCheck.length<2) 

if (StrForCheck.length==0) {alert("注意:输入框不能为空!");return false;} 

else 

{return true;} 

//--> 

</script> 

</head> 

<body> 

<form method="POST" name="form_key" onsubmit="return checkChinese();"> 

<input name="keywords" size="30" class="editbox1"> 

<input type=submit value=" 发 送 " class=bottom name="submit"> 

</form> 

</body> 

</html></td>

 </tr>

</table>


--结束END--

本文链接: http://www.eycms.cn/resources/dialog/1125.html (转载时请注明来源链接)

 
本文标签: 全部

下班PC阅读不方便?

手机也可以随时学习开发

微信关注公众号“亿搜云”
"亿搜云平台前端开发教学"
每日干货技术分享
 

×

成为 亿搜云平台 代理商!

关注

微信
关注

微信扫一扫
获取最新优惠信息

亿搜云平台公众号

客服

联系
客服

很高兴为您服务
尊敬的用户,欢迎您咨询,我们为新用户准备了优惠好礼。 咨询客服

联系客服:

在线QQ: 40819446

客服电话: 15250286283

售前咨询 售后服务
在线交谈 智能小云

工作时间:

周一至周五: 09:00 - 17:00

WAP

手机
访问

移动端访问
手机上也能选模板

亿搜云平台手机端