gpt4 book ai didi

javascript - 如何使用 Bootstrap 验证来验证所见即所得编辑器

转载 作者:太空宇宙 更新时间:2023-11-04 16:13:14 25 4
gpt4 key购买 nike

使用

bootstrap3-wysihtml5-bower 2013-11-22 (WYSIWYG Editor)

BootstrapValidator v0.5.2

使用引导验证验证文本区域(bootstrap-wysihtml5 编辑器)。只需要检查NotEmptyMax Characters 然后提交表单。

目前已经尝试过

$('#setpolicyform').bootstrapValidator({
message: 'This value is not valid',
feedbackIcons: {
valid: 'glyphicon glyphicon-ok',
invalid: 'glyphicon glyphicon-remove',
validating: 'glyphicon glyphicon-refresh'
},
ignore: ":hidden:not(textarea)",
fields: {
policyta: {
group: '.lnbrd',
validators: {
notEmpty: {
message: 'Textarea cannot be empty'
}
}
}
}
}).on('success.form.bv', function(e) {
e.preventDefault();
var $form = $("#setpolicyform"),
$url = $form.attr('action');
$.post($url, $form.serialize()).done(function(dte) {
$("#policy-content").html(dte);
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form role="form" method="POST" action="self.php" name="setpolicyform" id="setpolicyform">
<div class='box-body pad'>
<div class="form-group">
<div class="lnbrd">
<textarea class="form-control textarea" name="policyta" placeholder="Place some text here" style="width: 100%; height: 200px; font-size: 14px; line-height: 18px; border: 1px solid #dddddd; padding: 10px;"></textarea>
</div>
</div>
</div>
<div class="box-footer clearfix">
<button type="submit" class="btn btn-danger pull-right" id="setpolicyformsubmitbtn"><i class="fa fa-save"></i>&nbsp;SAVE</button>
</div>
</form>

JSFiddle https://jsfiddle.net/v6s0726L/1/

最佳答案

伙计们,bootstrapValidator 已经升级为 formValidation。如果您使用的是 formValidation 的更新版本,您可以这样做而不是添加一个单独的类来隐藏文本区域:

   $('#setpolicyform').formValidation({
framework: 'bootstrap',
excluded: [':disabled'], /* This will do the trick of validating for notEmpty*/
icon : {
valid : '',
invalid : '',
validating : 'glyphicon glyphicon-refresh'
},
fields: {
policyta: {
group: '.lnbrd',
validators: {
notEmpty: {
message: 'Textarea cannot be empty'
},
stringLength: {
max: 50,
message: 'Maximum 50 Characters Required'
}
}
}
}
});

$('.textarea').wysihtml5({
events: {
change: function () {
$('#setpolicyform').formValidation('revalidateField', 'policyta');
}
}
});

谢谢

关于javascript - 如何使用 Bootstrap 验证来验证所见即所得编辑器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33821071/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com