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


    使用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="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>







  • 相关阅读:
    mssql:tsql;创建表;给表添加约束;使用变量;事务,索引,视图;存储过程;触发器trigger;播放器http://www.smartgz.com/blog/Article/956.asp
    str.Replace(" ","");
    DataGrid分页;指定列的总和和平均值;显示鼠标背景色;弹出式窗口;
    .net 面试题 (1)
    数据绑定技术_单值数据绑定示例;将 DataTable,DataSet,DataView,DataReader 绑定到 DataGrid 控件示例;DataBinder.Eval;数组的值赋给ListBox1;Hashtable 绑定到;RadioButtonList;将XML 文件做为数据源绑定到控件
    Lession 17 Always young 保持年轻
    智力面试题
    Lession 16 A Polite request 彬彬有礼的要求
    几道 C 语言面试题
    建表的范例脚本,存储过程中参数的命名
  • 原文地址:https://www.cnblogs.com/gbin1/p/2352582.html
Copyright © 2020-2023  润新知