LigerUi验证

LigerUi验证方式一 类似于一下这种验证 nbsp nbsp nbsp scripttype text javascript nbsp nbsp nbsp dml 相关操作 nbsp nbsp nbsp nbsp nbsp varCurID 1 nbsp nbsp nbsp nbsp nbsp nbsp nbsp varValidator

方式一:类似于一下这种验证

    <script type=“text/javascript”>

    //————————————dml相关操作———————————————–

      var CurID = 1;

        var Validator = null;[d1] 

        var editor_description;  

        $(function ()

        {         

           $(“#infoform”).ligerForm();

           //验证信息

           $.metadata.setType(“attr”, “validate”);

           deafultValidate($(“#infoform”));

           Validator = $(“#infoform”).validate();

[d2] [d3]            $(“#title”).focus();

        });      

      function f_success() {

     $.ligerDialog.closeWaitting();

      $.ligerDialog.success(保存成功,“”,function(button,domobject,buttonindex){

       top.frames[“TabArticle”].f_reload();

       LG.closeCurrentTab(‘TabArticleModify’);

   

     });

     }

        function f_error(message)

        {

            $(document).ready(function(){

                $.ligerDialog.error(message);

            });

        }

         //按钮提交

      function f_post(){   

      var nid=$(“#nid”).val();

      var rootid=$(“#rootid”).val();

            var options = {

            target:,

            url:‘article!save.action?nid=’+nid, 

            type:‘POST’,

            success: function(data,textStatus){

            if(data==‘false’){

               $.ligerDialog.closeWaitting();

               $.ligerDialog.error(保存失败);

            }else if(data==‘true’){

                f_success();

            }

            }};

            $(‘#infoform’).ajaxSubmit(options);

      }

     

        function f_save()

        {       

         if(!Validator.form()) return;

             $(“form”).ligerForm();

[d4]             

          editor_description.sync(); 

            $.ligerDialog.waitting(正在保存中…”);

             setTimeout(function(){

                f_post();

            },10);

        }

      

   
script>

   <style type=“text/css”>

 

    body{ font-size:12px;padding:20px;}

        .l-table-edit {}

        .l-table-edit-td{ padding:4px;}

        .l-button-submit,.l-button-test{
width:80px; float:left; margin-left:10px; padding-bottom:2px;}

        .l-verify-tip{ left:230px; top:120px;}

   
style>

 

 
head>

 

  <body>

    <div>

   <form id=“infoform” action=“” method=“post” >

   <input type=“hidden” name=“articleid” id=“articleid” value=${articleid}/>

    <input type=“hidden” id=“nid”  value=${nid}/>

    <input type=“hidden” name=“rootid” id=“rootid” value=${rootid}/>

  

       

         <table cellpadding=“0” cellspacing=“0” class=“l-table-edit”  align=“left”  >          

            <tr>

                <td  class=“l-table-edit-td”>标题:
td>

               <td   class=“l-table-edit-td”  colspan=“2”><input  ligerui=“{width:600}” name=“title” value=${title} type=“text” id=“title” 

                validate=“{required:true,minlength:1,maxlength:50}” [d5] />
td>               

                <td align=“left”><font color=“red”>*
font>
td>

           
tr>

           <tr>

                <td  class=“l-table-edit-td”>摘要:
td>

                <td class=“l-table-edit-td” style=”width:600pxcolspan=“2”>

                <textarea cols=“100” rows=“5” class=“l-textarea” id=“abstract_” name=“abstract_” style=”width:600px

                validate=“{required:true,minlength:1,maxlength:100}” >${abstract_}
textarea>

              
td>

                <td align=“left”><font color=“red”>*
font>
td>

           
tr>

           <tr>

                <td class=“l-table-edit-td” valign=“top”>首页显示
td>

                <td  class=“l-table-edit-td” style=”width:160px>

                    <input id=“rbtnl_0” type=“radio” name=“isnotice” value=“1”  <c:if test=${isnotice==1}>checked
c:if> /><label for=“rbtnl_0”>
label>    

                  <input id=“rbtnl_1” type=“radio” name=“isnotice” value=“0”  <c:if test=${isnotice==0||isnotice==”}>checked
c:if>/><label for=“rbtnl_1”>
label>

               
td>              

                <td class=“l-table-edit-td” style=”width:160px>
td>

                <td align=“left”>
td>

           
tr>  

           <tr>

                <td class=“l-table-edit-td”>正文:
td>

                <td  class=“l-table-edit-td” colspan=“2”>               

                <textarea id=editor_description name=“content” style=”width:600px;height:300px;”>${content}
textarea>

               
td>

                <td align=“left”>
td>

           
tr>     

       
table>

          

  
form>

  
div>

 

      <script type=“text/javascript”>

     $(function() {

     KindEditor.ready(function(K) {

      editor_description = K.create(‘#editor_description’, {

      resizeType : 0, //2102时可以拖动改变宽度和高度,1时只能改变高度,0时不能拖动。

      allowPreviewEmoticons : false,//true时鼠标放在表情上可以预览表情。

      allowImageUpload : false,

      items : [‘source’,‘fontname’, ‘fontsize’, ‘|’, ‘forecolor’, ‘hilitecolor’, ‘bold’, ‘italic’, ‘underline’,

                    ‘removeformat’, ‘|’, ‘justifyleft’, ‘justifycenter’, ‘justifyright’, ‘insertorderedlist’,

                    ‘insertunorderedlist’, ‘|’, ‘table’]

      });

   });

     });  

    

   LG.setFormDefaultBtn(f_cancel,f_save);

  

[d6]   
script>

 
body>


html>

 

方式二:

 

 

 

 


 [d1]第一:

申明一个验证用的变量

 [d2]第二:

在初始化函数中把表单绑定到验证变量上

 [d3]第三:

如果添加失败,返回页面聚焦到标题输入框

 [d4]第四:

save方法点击后,先验证

save

 [d5]第五:

页面上运用验证变量。限制输入字符大小。

 [d6]定义tab下面的确定和取消按钮。

需要再LG.js里面看setFormDefaultBtn()方法是否写了。否则按钮也不会出来。

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/226264.html原文链接:https://javaforall.net

(0)
上一篇 2026年3月16日 下午11:57
下一篇 2026年3月16日 下午11:57


相关推荐

  • 一起学JAVA 继承 super

    一起学JAVA 继承 super1 继承 1 1 概念继承是面向对象最显著的一个特征继承是从已有的类中派生出新的类 新的类能吸收已有类的数据属性和行为 并扩展新的能力 Java 继承是会用已存在的类的定义作为基础建立新类的技术新类的定义可以增加新的数据或者新的功能 也可以使用父类的功能 但不能选择性的继承父类 超类 基类 这种继承使得复用以前的代码非常容易 能够大大的缩短开发的周期 降低开发费用 1 2 特点使用 extends 关键字来表示继承关系相当于子类把父类的功能复制了一份 Java 只支持单继承继承可以传递 爷爷 儿子

    2026年3月18日
    3
  • 中文词向量大全[通俗易懂]

    中文词向量大全[通俗易懂]#中文词向量大全https://github.com/Embedding/Chinese-Word-Vectors里面有词向量下载(很多的类型)#使用方法下载后加载方式:unicode字符哦!importgensimfromgensim.modelsimportKeyedVectorsmodel=KeyedVectors.load_word2vec_format…

    2022年5月3日
    80
  • imfill简介_im ill

    imfill简介_im illBW2=imfill(BW)这种格式将一张二值图像显示在屏幕上,允许用户使用鼠标在图像上点几个点,这几个点围成的区域即要填充的区域。要以这种交互方式操作,BW必须是一个二维的图像。用户可以通过按Backspace键或者Delete键来取消之前选择的区域;通过shift+鼠标左键单击或者鼠标右键单击或双击可以确定选择区域。[BW2,locations]=imfill(BW)

    2025年11月8日
    7
  • Android数据库框架——GreenDao轻量级的对象关系映射框架,永久告别sqlite

    Android数据库框架——GreenDao轻量级的对象关系映射框架,永久告别sqlite

    2021年9月16日
    62
  • L2-004这是二叉搜索树吗(二叉搜索树)

    L2-004这是二叉搜索树吗(二叉搜索树)原题链接一棵二叉搜索树可被递归地定义为具有下列性质的二叉树:对于任一结点,其左子树中所有结点的键值小于该结点的键值;其右子树中所有结点的键值大于等于该结点的键值;其左右子树都是二叉搜索树。所谓二叉搜索树的“镜像”,即将所有结点的左右子树对换位置后所得到的树。给定一个整数键值序列,现请你编写程序,判断这是否是对一棵二叉搜索树或其镜像进行前序遍历的结果。输入格式:输入的第一行给出正整数 N(≤1000)。随后一行给出 N 个整数键值,其间以空格分隔。输出格式:如果输入序列是对一棵二叉搜索树或

    2022年8月9日
    7
  • 最新Claude注册攻略详解,快速入门必看技巧

    最新Claude注册攻略详解,快速入门必看技巧

    2026年3月15日
    2

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号