我想用Javascript来验证用户输入的信息是否符合标准
<form action="check.php" method="post" onsubmit="CheckInfo(this)">
上边是form便签里的内容下边是Javascript的内容
我的问题是 为什么我在点了submit以后 网页好像对Javascript没有反应 直接跳转了 请大侠解惑 谢谢
<script language="javascript"> function CheckInfo()
{
var userName;
var userEmail;
var userGender;
var userComments; if(!isEmpty(name))
{
userName=name;
}
else
alert("please enter your name");
return false;
}
if(!isEmpty(email))
{
userEmail=email;
}
else
{
alert("please enter your email");
return false;
}
if(isset(gender))
{
userGender=gender;
}
else
{
alert("please select your gender");
return false;
}
if(!isEmpty(comments))
{
userComments=comments;
}
else
{
alert("please enter your comments");
return false;
}
alert("welcome to regist!");
return true;
}
</script>
<form action="check.php" method="post" onsubmit="CheckInfo(this)">
上边是form便签里的内容下边是Javascript的内容
我的问题是 为什么我在点了submit以后 网页好像对Javascript没有反应 直接跳转了 请大侠解惑 谢谢
<script language="javascript"> function CheckInfo()
{
var userName;
var userEmail;
var userGender;
var userComments; if(!isEmpty(name))
{
userName=name;
}
else
alert("please enter your name");
return false;
}
if(!isEmpty(email))
{
userEmail=email;
}
else
{
alert("please enter your email");
return false;
}
if(isset(gender))
{
userGender=gender;
}
else
{
alert("please select your gender");
return false;
}
if(!isEmpty(comments))
{
userComments=comments;
}
else
{
alert("please enter your comments");
return false;
}
alert("welcome to regist!");
return true;
}
</script>
解决方案 »
- 请问 设置了set_time_limit 为何页面还会 504错误?
- 网站后台,进行用户验证,安全性问题,请进
- php如何通过byte生成图片jpg
- 关于页面编码的问题
- 10M-50M文件上传,有那些比较好的方法?在线等待
- 使用php写网络爬虫
- php+mysql 可以在win2000+iis环境下运行吗?
- mysql管理界面报出的错误!Host '127.0.0.1' is blocked because of many connection errors. Unblock with 'mysqladmin flush-hosts'
- 庆祝零的开始!
- 急,谁有这经验???
- 菜鸟问题
- php初学者问题
这两个是php中有的函数。lz 还是学学学javascript吧
给一段我最近用到了的验证代码给你,小小的用到了Ajax哦:
function $(idname){
return document.getElementById(idname);
}
function load(){
$('reg_username').focus();
}
function checkname(){
var username=$('reg_username').value;
if(username!=''){
if(username.length < 4 || username.length > 20){
$('reg_username').value="";
$('checkname').innerHTML='<font color=red size=1>error 用户名长度为4-20</font>';
return false;
}else{
check_regname();
}
}else{
$('checkname').innerHTML='<font color=red size=1>error 用户名长度不能为空</font>';
return false;
}
}