<script language=javascript>
//要求一
if(document.text1.value==''||document.text2.value=='')
{
alert('1');
}
//要求二
email=document.text1.value;
if((at=email.indexOf("@"))<0){
email_ok=false;
}
if((dot=email.lastIndexOf("."))<0){
email_ok=false;
}
if(at>dot||dot>=email.length-1){
email_ok=false;
}
if(!email_ok){
alert("填写 EMail 错误!");
return false;
}
//要求三
if(document.text1.value<=0)
{
alert('3');
}
//要求一
if(document.text1.value==''||document.text2.value=='')
{
alert('1');
}
//要求二
email=document.text1.value;
if((at=email.indexOf("@"))<0){
email_ok=false;
}
if((dot=email.lastIndexOf("."))<0){
email_ok=false;
}
if(at>dot||dot>=email.length-1){
email_ok=false;
}
if(!email_ok){
alert("填写 EMail 错误!");
return false;
}
//要求三
if(document.text1.value<=0)
{
alert('3');
}
解决方案 »
- 页面验证jS较多,不符合验证的,均获得焦点重新输入,但是这样导致页面死掉
- Ext如何设置Form的each的readOnly
- JS WORD文档的转换问题 ? 急等
- cloneNode的问题
- 怎么实现点击单选框旁边表格弹出一个文本框
- javascript指定frame里显示特定网页的问题,把我弄蒙了!
- 有没有那种把窗口的滚动条还有标题栏状态栏都去掉的javascript??? 十分钟结账
- 关于字码问题
- 100-高分急等,如何做一个自动的计算器,
- 高分儿!等待回答的小问题!!!!!!!!!
- 做过搜索引擎的都过来啊! 关于搜索引擎,已能高速 获取第一关键字id 求救怎么再次检索(既合并关键字)!
- 怎样才能把树中的一节点通过鼠标移动到另一节点下
var text2=document.getElementById("text2");if(text1.value=="" || text2.value=="")
{
alert("please input first!!");
return false;
}if(parseInt(text2.value)<=0)
{
alert("text2 should >0!!");
return false;
}if(text1.value.indexOf("@")<=0 || text1.value.indexOf("@")==text1.value.length-1)
{
alert("text1 should be validated email address!!");
return false;
}
<head>
<script language="JavaScript">
<!--
function check(){
if(text1.value=="" && text2.value==""){
alert("不能都为空!"); return;
}
if(!testEmail(text1.value)){
alert("Email格式不合法!"); return ;
}
if(parseInt(text2.value,10)<=0){
alert("文本框值应该大于零!"); return ;
}
}
function testEmail(str){
var reg=/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
return reg.test(str);
}
//-->
</script>
</head>
<body>
<input type="text" name="text1" value="[email protected]">
<input type="text" name="text2" value="-20">
<input type="button" onclick="check()" value="check">
</body>
</html>