- r.prompt = function(e, t) {
- var a = "";
- if (e = e || {},
- "function" == typeof e && (t = e), e.area) {
- var o = e.area;
- a = 'style="width: ' + o[0] + "; height: " + o[1] + ';"',
- delete e.area
- }
- var s, l = 2 == e.formType ? '<textarea class="layui-layer-input"' + a + ' placeholder="' + (e.placeholder?e.placeholder:'') + '"></textarea>': function() {
- return '<input type="' + (1 == e.formType ? 'password': 'text') + '" placeholder="' + (e.placeholder?e.placeholder:'') + '" class="layui-layer-input">'
- } (),
- f = e.success;
- return delete e.success,
- r.open(i.extend({
- type: 1,
- btn: ["确定", "取消"],
- content: l,
- skin: "layui-layer-prompt" + c("prompt"),
- maxWidth: n.width(),
- success: function(t) {
- s = t.find(".layui-layer-input"),
- s.val(e.value || "").focus(),
- "function" == typeof f && f(t)
- },
- resize: !1,
- yes: function(i) {
- var n = s.val();
- "" === n ? s.focus() : n.length > (e.maxlength || 500) ? r.tips("最多输入" + (e.maxlength || 500) + "个字数", s, {
- tips: 1
- }) : t && t(n, i, s)
- }
- },
- e))
- },
- layer.prompt({
- formType: 0, //输入框类型,支持0(文本)默认1(密码)2(多行文本)
- maxlength: 12, //限制长度
- value: '', //初始时的值,默认空字符
- title: '标题', //标题
- placeholder: '提示信息', //提示信息,默认空字符
- area: ['400px', '22px']//自定义文本域宽高
- }, function(value, index){
- console.log(value,index);
- layer.close(index);
- });