使用jQuery插件开发一个完整验证功能的超酷动态留言版系统

本文介绍了一个使用jQuery插件创建的情人节动态留言板系统。该系统具备动态显示输入框、输入提示及表单验证等功能,旨在提升用户体验。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

日期:2012/02/14  来源:GBin1.com

使用jQuery插件开发一个完整验证功能的超酷动态留言版系统

在线演示 本地下载

今天是情人节,这里我们将创建一个超酷的动态留言板来帮助大家度过这个情人节,可能大家使用过很多的评论或者留言系统,基本都是静态输入的形式,今天我们创建的这个留言板灵感来自于一些超棒的网页设计,在用户输入过程中,会动态的显示输入框,产生类似flash的效果。提高用户的体验。希望大家喜欢!

注:由于使用了Cufon英文字体美化UI界面,所有不支持中文输入,如果你需要输入中文,请将Cufon相关代码移除即可。

jQuery插件

1. jQuery validation engine plugin  -  表单验证插件

2. jQuery placehoder plugin  -  输入提示插件

3. jQuery pretty form plugin  -  美化表单插件

4. Cufon  - 美化字体类库

Javascript代码

以下代码生成输入框和textarea的背景效果:

/* ---------------------------------------------------------------------- */
/*	GBin1.com Living form
/* ---------------------------------------------------------------------- */
$(function(){
    $(".input-wrapper").livingElements("img/input-mask-white.png", {
        background: "url('img/living-gradient.png') no-repeat",
        easing: 'linear',
        triggerElementSelector: 'input',
        mainAnimationStartOpacity: 0,
        mainAnimationEndOpacity: 1,
        mainAnimationDuration: 800
    });
    
    $(".textarea-wrapper").livingElements("img/textarea-mask.png", {
        background: "url('img/textarea-gradient.jpg') no-repeat",
        easing: 'linear',
        triggerElementSelector: 'textarea',
        preAnimationStartOpacity: 0,
        mainAnimationFade: false,
        scrollDirection: 'horizontal',
        mainAnimationDuration: 1500,
        mainAnimationStartBackgroundPositionX: -200,
        mainAnimationEndBackgroundPositionX: 0,
        postAnimationEndOpacity: 0
    });
});

以上代码分别使用不同的效果来动态展示输入效果。输入内容提示,及其表单验证如下:
$(function(){
	Cufon.replace('h1, div, input').CSS.ready(function() {
		$('input[placeholder], textarea[placeholder]').placeholder();

		$("#commentform").validationEngine('attach');
		$("#submit").click(function(){
			if(!$("#commentform").validationEngine('validate')){
				return;
			}
			var mail,name,comments;
			mail = $("#mail").val();
			name = $("#name").val();
			comments = $("#comment").val();
			$("#comments").hide().append("<div class=\"item\">" + name + " (" + mail + "): " + new Date() + "</div><div class=\"itemtxt\">" + comments+ "</div>").fadeIn(1000);
			Cufon.refresh();
		});
	});
});




以上代码中,我们判断是否输入,然后,提示用户输入内容。完成后,调用Cufon.refresh()方法来生成界面字体。

HTML

<h1>Super Cool Live Comment Box</h1>
<form method="post" id="commentform" style="width:400px">
	
	<div  id="living-effect" class="input-wrapper">
		<input class="living-input validate[required,custom[email]]" id="mail" type="text" placeholder="Your email...">
	</div>		

	<div  id="living-effect" class="input-wrapper">
		<input class="living-input validate[required]" id="name" type="text" placeholder="Your name...">
	</div>	
	
	<div  id="living-effect" class="textarea-wrapper">
		<textarea class="living-textarea validate[required]" id="comment" type="text" placeholder="Your comments..."></textarea>
	</div>		
	
	<div  class="submit-wrapper">
		<input value="submit" id="submit" class="living-submit" style="color:#808080;padding: 10px 46px 11px;margin-left:15px;font-size:14px" type="button">
	</div>
	
	<div  class="info-wrapper">
		<div id="comments"></div>
	</div>
</form>


CSS

@charset "utf-8";

body{
    background: #E8E8E8;
	font-size: 14px;
	font-family: verdana;
}


#container{
	margin: 0 auto;
	background: #fff;
	width: 600px;
	color: #333;
	padding: 15px;
	margin-top: 0;
	height: 100%;
}

h1{
	padding: 0 0 0 25px;
	font-weight: bold;
	font-size: 48px;
	color: #505050;
}

section{
	height: 100%;
}

#comments{
	padding: 10px 5px;
	font-size: 12px;
	color: #808080;
}

.item{
	border-top: 1px dotted #CCC;
	font-size:14px;
	color:#808080;
	padding:20px 0 20px;
}

.itemtxt{
	font-size:12px;
	color:#808080;
	padding:20px 0 20px;
}

*:focus {outline: none;}

.input-wrapper
{
	width:275px;
	height:80px;
	background:url(../img/input-bg.png);
	margin-left:10px;
	float:left;
}

.submit-wrapper
{
	width:250px;
	height:80px;
	margin-left:10px;
	float:left;
}

.input-mask
{
	background:url(../img/input-mask.png);
	width:275px;
	height:80px;
}

.living-input
{
	padding:5px 5px 5px 5px;
	margin:27px 0px 0px 24px;
	width:217px;
	background:none;
	border:none;
	color:#909090;
	font-size:14px;
	font-family:Arial, Helvetica, sans-serif;
	font-weight:normal;
	float:left;
	box-shadow: 0 0 0 0;
}

.living-submit
{
	padding:15px 5px 15px 12px;
	margin:20px 0px 0px 24px;
	width:217px;
	background: #E1E1E1;
	border: 1px solid #ccc;
	color:#CCCCCC;
	font-size:14px;
	font-family:Arial, Helvetica, sans-serif;
	font-weight:normal;
	float:left;
	box-shadow: 0 0 0 0;
}

.living-textarea
{
	padding:5px;
	margin:16px 0px 0px 12px;
	width:500px;
	height:160px;
	background:none;
	border:none;
	color:#909090;
	font-size:15px;
	font-family:Arial, Helvetica, sans-serif;
	box-shadow: 0 0 0 0;
}

.textarea-wrapper
{
	width:534px;
	height:206px;
	background:none;
	margin-left:19px;
	float:left;
}

.info-wrapper{
	width: 600px;
	height:206px;
	background:none;
	margin-left:19px;
	float:left;
	padding: 10px 0px;
}


来源:使用jQuery插件开发一个完整验证功能的超酷动态留言版系统


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值