其他分享
首页 > 其他分享> > layiui 富文本

layiui 富文本

作者:互联网

content富文本域中的lay-verify值

<style type="text/css">
    #myForm{
        background: white;
        padding: 30px;
    }
</style>
<form id="myForm" method="post" class="layui-form white-bg radius">
    <div class="layui-form-item">
        <label class="layui-form-label">标题</label>
        <div class="layui-input-block">
            <input type="text" class="layui-input" name="title" >
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">发布人</label>
        <div class="layui-input-block">
            <input type="text" class="layui-input" name="name" >
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">内容</label>
        <div class="layui-input-block">
            <textarea id="lay_edit" lay-verify="content" name = "text" ></textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button type="submit" lay-submit="" class="layui-btn layui-btn-radius layui-btn-normal" style="width: 150px" lay-filter="formSubmit" >保存</button>
        </div>
    </div>
</form>
 
<script>
    layui.use(['layedit', 'form'], function(){
        var form = layui.form;
        var layedit = layui.layedit;
        layedit.set({   //设置图片接口
            uploadImage: {
                url: 'layEdit/upload', //接口url
                type: 'post'
            }
        });
        //创建一个编辑器
        var index = layedit.build('lay_edit',{
            height: 350
        });
        //提交时把值同步到文本域中
        form.verify({
            //content富文本域中的lay-verify值
            content: function(value) {
                return layedit.sync(index);
            }
        });
 
        form.on("submit(formSubmit)", function (data) {
            console.log(data.field);
            $.post("layEdit/save", data.field, function(result){
                layer.msg(result.msg,{offset:'rb'});
            });
            return false;  
        })
    });
</script>

标签:function,form,verify,content,layiui,var,文本,layedit
来源: https://blog.csdn.net/qypt2015/article/details/123084103