模仿网易邮箱做了一个登录表单验证,不太好,请指教

上代码

<form action="" name="" id="form1">
<div class="changepwd">
<ul>
<li>
<input type="text" class="text_100per" value="">
<p>请填写用户名,会员名不能为空</p>
<span>昵称</span>
</li>
<li>
<input type="text" class="text_100per" value="">
<p>请填写邮箱,不能为空</p>
<span>邮箱</span>
</li>
<li>
<input type="text" class="text_100per" value="">
<p>请填写密码,不能为空</p>
<span>密码</span>
</li>
<li>
<input type="text" class="text_100per" value="">
<p>请再次填写密码,不能为空</p>
<span>确认密码</span>
</li> <li>
<input type="text" class="text_100per" value="">
<p></p>
<span>确认新密码</span>
</li>
<li class="validtext"><input type="text" class="text_40per" value="验证码" onBlur="if(this.value==''){this.value='验证码'}" onFocus="if(this.value=='验证码'){this.value=''}"> <img src="valid.jpg"><div class="clear"></div></li>
<li class="maksure"><input type="image" class="imp" src="data:images/changepwd.jpg" alt="确定修改" title="确定修改"></li>
</ul>
</div>
</form>

css

.changepwd {width:94%;margin:12px auto 12px;}
.changepwd ul {}
.changepwd ul li {height:auto;position:relative;padding-bottom:5px;}
.changepwd ul li p {font:12px/20px Helvetica;color:#999;}
.changepwd ul li span {display:block;position:absolute;left:;top:;z-index:-1;color:#333;padding:0 3%;width:94%;font:14px/34px Helvetica;color:#333;}
.maksure {padding-top:12px;}
.maksure .imp {display:block;width:100%;}

js

(function($){
$.fn.beauForm = function(){
var beau = function(arg){
var argOli = arg.find('li');
argOli.each(function(index,element){
var _this = $(this);
var oInp = $(this).find('input') || $(this).find('textarea');
var oTex = $(this).find('textarea');
oInp.focus(function(e) {
if(oInp.val() == '' || oTex.text() == ''){
_this.find('span').css({'color':'#aaa'});
_this.find('p').css({'color':'#f00'});
_this.find('input').css({'border':'solid 1px #f00'});
}
else{
_this.find('span').text('');
_this.find('p').css({'color':'#999'});
_this.find('input').css({'border':'solid 1px #ccc'});
}
});
$(document).keyup(function(e) {
if(oInp.val() != ''){
_this.find('span').text('');
_this.find('p').css({'color':'#999'});
_this.find('input').css({'border':'solid 1px #ccc'});
}else{
_this.find('span').text('');
_this.find('p').css({'color':'#999'});
_this.find('input').css({'border':'solid 1px #ccc'});
}
});
oInp.blur(function(e) {
if(oInp.val() == '' || oTex.text() == ''){
_this.find('span').css({'color':'#333'});
_this.find('span').text(tex);
_this.find('p').css({'color':'#f00'});
_this.find('input').css({'border':'solid 1px #f00'});
}else{
_this.find('span').text('');
_this.find('p').css({'color':'#999'});
_this.find('input').css({'border':'solid 1px #ccc'});
}
}); });
var Inp = 'mc';
}; return $(this).each(function(index, element) {
beau($(this));
});
};
})(jQuery);

调用:

<script src="js/beauForm.js"></script>
<script> $('#form1').beauForm(); </script>

还行,赶时间做了一个,知道不太完美不过还得接着完善
哪位好心哥哥帮提提意见也成 ^_^

jQuery封装的表单验证,模仿网易或者腾讯登录的风格的更多相关文章

  1. 基于jQuery的Validate表单验证

    表单验证可以说在前端开发工作中是无处不在的~ 有数据,有登录,有表单, 都需要前端验证~~  而我工作中用到最多的就是基于基于jQuery的Validate表单验证~  就向下面这样~ 因为今天有个朋 ...

  2. jquery.validation.js 表单验证

    jquery.validation.js 表单验证   官网地址:http://bassistance.de/jquery-plugins/jquery-plugin-validation jQuer ...

  3. Jquery.validate.js表单验证插件的使用

    作为一个网站web开发人员,以前居然不知道还有表单验证这样好呀的插件,还在一行行写表单验证,真是后悔没能早点知道他们的存在. 最近公司不忙,自己学习一些东西的时候,发现了validation的一个实例 ...

  4. 基于Jquery Validate 的表单验证

    基于Jquery Validate 的表单验证 jquery.validate.js是jquery下的一个验证插件,运用此插件我们可以很便捷的对表单元素进行格式验证. 在讲述基于Jquery Vali ...

  5. 异步提交form的时候利用jQuery validate实现表单验证

    异步提交form的时候利用jQuery validate实现表单验证相信很多人都用过jquery validate插件,非常好用,并且可以通过下面的语句来自定义验证规则    // 电话号码验证    ...

  6. 基于Bootstrap+jQuery.validate Form表单验证实践

    基于Bootstrap jQuery.validate Form表单验证实践 项目结构 :     github 上源码地址:https://github.com/starzou/front-end- ...

  7. jQuery.validate.js表单验证插件

    jQuery.validate.js表单验证插件的使用 效果: 代码: <!DOCTYPE html> <html lang="en"> <head& ...

  8. jQuery Validation Engine 表单验证,自定义规则验证方法

    jQuery Validation Engine 表单验证说明文档http://code.ciaoca.com/jquery/validation-engine/ js加到jquery.validat ...

  9. 自己编写jQuery插件之表单验证

    自己编写jQuery插件之表单验证 吐个嘈先:最近状态不咋滴,真是什么都不想干,不想上班,做什么都没动力,觉得没意思.不想这样,不想这样,快让这种情绪消失吧,忽忽.... 表单验证在项目中用的还是比较 ...

随机推荐

  1. 转载:css3 box-shadow投影发光效果

    转载网址:http://www.wufangbo.com/css3-box-shadow/ CSS3的box-shadow属性 可以让我们轻松实现图层阴影效果.我们来实战详解一下这个属性. 1. bo ...

  2. mysql用户修改密码

    1: 用SET PASSWORD命令 首先登录MySQL. 格式:mysql> set password for 用户名@localhost = password('新密码'); 2:用mysq ...

  3. destoon系统商城加淘宝客按钮方法

    destoon系统很多喜欢运营B2B的站长都在用,其中的商城模块常常被用来做淘宝客,其中的难点是如何把购买按钮做成淘宝客地址,这个问题的修改在论坛上被叫价50元,下面小编把这个实用的方法分享下,希望对 ...

  4. C语言初学 俩数相除问题

    #include<stdio.h> #include<stdlib.h> main() { double a,b;                       scanf(&q ...

  5. cf C. Knight Tournament

    http://codeforces.com/contest/357/problem/C #include <cstdio> #include <cstring> #includ ...

  6. 用keil直接生成BIN文件

    1.下载hex2bin到keil的任意目录,下载地址:http://www.keil.com/download/docs/7.asp 或者 http://www.hex2bin.com/files/h ...

  7. HDU4893--Wow! Such Sequence! (线段树 延迟标记)

    Wow! Such Sequence! Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Oth ...

  8. Codeforces Round #327 (Div. 1) D. Top Secret Task

    D. Top Secret Task time limit per test 3 seconds memory limit per test 256 megabytes input standard ...

  9. ibatis学习之道:ibatis的<[CDATA]>dynamic属性跟#$的应用

    ibatis的<![CDATA]>,dynamic属性和#,$的应用 <![CDATA[   ]]>的正确使用 ibatis作为一种半自动化的OR Mapping工具,其灵活性 ...

  10. URAL 1036

    题目大意:求前N位与后N位各个位和相等且总和等于S的2N位数的个数. KB     64bit IO Format:%I64d & %I64u 数据规模:1<=N<=50,0< ...