JS实现表单验证
2011-12-17 02:47
513 查看
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css">
<!--
body,td,th {
font-size: 12px;
color: #000000;
}
body {
background-color: #CCCCCC;
margin-left: 0px;
margin-top: 0px;
}
a {
font-size: 12px;
color: #666600;
}
a:link {
text-decoration: none;
}
a:visited {
text-decoration: none;
color: #000099;
}
a:hover {
text-decoration: underline;
color: #6633FF;
}
a:active {
text-decoration: none;
color: #00FF00;
}
-->
</style>
<script type="text/javascript">
function checkusername()
{
var myform = document.getElementByIdx_x_x("form1");
var username = myform.username.value.length;
if(username < 1||username>12)
{
errusername.innerHTML = "<font color='red'>用户名不符合要求</font>";
return false;
}else{
errusername.innerHTML = "<font color='green'>用户名符合要求</font>";
return true;
}
}
function checkage()
{
var myform = document.getElementByIdx_x_x("form1");
var age = myform.age.value;
if(age != parseInt(age))
{
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css">
<!--
body,td,th {
font-size: 12px;
color: #000000;
}
body {
background-color: #CCCCCC;
margin-left: 0px;
margin-top: 0px;
}
a {
font-size: 12px;
color: #666600;
}
a:link {
text-decoration: none;
}
a:visited {
text-decoration: none;
color: #000099;
}
a:hover {
text-decoration: underline;
color: #6633FF;
}
a:active {
text-decoration: none;
color: #00FF00;
}
-->
</style>
<script type="text/javascript">
function checkusername()
{
var myform = document.getElementByIdx_x_x("form1");
var username = myform.username.value.length;
if(username < 1||username>12)
{
errusername.innerHTML = "<font color='red'>用户名不符合要求</font>";
return false;
}else{
errusername.innerHTML = "<font color='green'>用户名符合要求</font>";
return true;
}
}
function checkage()
{
var myform = document.getElementByIdx_x_x("form1");
var age = myform.age.value;
if(age != parseInt(age))
{
相关文章推荐
- JS实现表单验证输入框提示
- JS验证表单实现
- JS实现的简单表单验证功能完整实例
- JS实现表单验证
- js实现表单验证 常用JS表单验证
- JS实现表单验证功能(验证手机号是否存在,验证码倒计时)
- JS实现支持Ajax验证的表单插件
- 原生js实现表单的正则验证,所有验证都通过后提交按钮才可用
- js实现表单验证(submit /button)
- js高级编程------------使用prototype仿java对象实现表单验证
- 一个流行且实用的JS表单验证提示,演示了怎么自定义错误信息的显示方式,同时通过写FormValid.showError类方法来实现错误显示方式自定义: errMsg 是一个错误消息的数组,这样方便自定
- Html JS实现表单验证
- ajax+php+js实现异步刷新表单验证
- JS实现的表单验证和强大的身份证
- 使用validate.js实现表单数据提交前的验证方法
- JS实现简单的表单验证01
- 纯JS实现表单验证实例
- 如何实现完美的表单验证?js? jquery? struts? ajax?
- JS的实现简单的表单验证
- 东软JavaWeb实训记-DAY2-Oracle开发+注册页表单验证+用户协议倒数js效果实现