求大神帮忙看下input设置默认的value值无效

qq_38975980 2017-06-19 10:18:04
<input id="customer-chat-login-mail" type="email" class="customer-chat-content-message-input-field" placeholder="abc@qq.com" value="abcd@qq.com">

这个input只显示placeholder的值,value的值死活都不读,求大神看下下面的js,给指导下,谢谢了

function(t, e, i) {
t.LoginFormView = Backbone.View.extend({
events: {
"click .select-department": "showDepartments"
},
mailExp: new RegExp("^[-+\\.0-9=a-z_]+@([-0-9a-z]+\\.)+([0-9a-z]){2,}$", "i"),
nameValid: !1,
mailValid: !1,
initialize: function() {
this.model = t.model.chat,
this.selectDepartment = this.createSelectDepartmentView(),
this.$form = this.$(".form"),
this.$name = this.$("#customer-chat-login-name"),
this.$mail = this.$("#customer-chat-login-mail"),
this.$departmentsBtn = this.$(".select-department"),
this.listenTo(this.selectDepartment, "updateSelection", this.onSelectDepartment),
this.$name.on("input change keydown blur", e.proxy(this.validateName, this)),
this.$mail.on("input change keydown blur", e.proxy(this.validateMail, this)),
this.reset()
},
reset: function() {
var t = this.model.departments;
t && 0 !== t.length ? this.$departmentsBtn.parent().show() : this.$departmentsBtn.parent().hide(),
this.$name.val(""),
this.$mail.val(""),
this.$name.removeClass("customer-chat-input-error"),
this.$mail.removeClass("customer-chat-input-error"),
"true" !== i.ui.askForMail && this.$mail.hide().val("anonymous@anonymous.anonymous")
},
validateDepartment: function() {
var e = !1,
i = this.model.departments;
if (!i || 0 === i.length) return void(this.departmentValid = !0);
if (this.selectDepartment.selected.length > 0 && (e = !0), e) {
var s = _.findWhere(t.model.chat.departments, {
id: this.selectDepartment.selected[0]
});
this.$departmentsBtn.removeClass("customer-chat-input-error").addClass("selected").find(".empty-content").hide().end().find(".content").html(s.name).show(),
this.departmentValid = !0
} else this.$departmentsBtn.addClass("customer-chat-input-error").find(".empty-content").show().end().find(".content").hide(),
this.departmentValid = !1
},
validateName: function() {
0 == this.$name.val().length ? (this.$name.addClass("customer-chat-input-error"), this.nameValid = !1) : (this.$name.removeClass("customer-chat-input-error"), this.nameValid = !0)
},
//怀疑是这里的问题!!!!
validateMail: function() {
0 != this.$mail.val().length && this.mailExp.test(this.$mail.val()) ? (this.$mail.removeClass("customer-chat-input-error"), this.mailValid = !0) : (this.$mail.addClass("customer-chat-input-error"), this.mailValid = !1)
},
isValid: function() {
return this.validateDepartment(),
this.validateName(),
this.validateMail(),
this.departmentValid && this.nameValid && this.mailValid
},
showDepartments: function() {
this.$el.addClass("departments-view")
},
hideDepartments: function() {
this.$el.removeClass("departments-view")
},
onSelectDepartment: function() {
this.validateDepartment(),
this.hideDepartments()
},
createSelectDepartmentView: function() {
return new t.SelectListView({
el: this.$(".departments .list"),
model: this.model,
single: !0,
iconActive: "check",
iconInactive: "circle",
renderEvent: "departments:change",
dataProvider: function() {
var e = t.model.chat.departments;
if (e) {
e = _.groupBy(e, "status");
var i = e.online || [],
s = e.offline || [];
return i.concat(s)
}
return []
},
getLabel: function(t) {
return "<div><span>" + t.name + "</span>" + (t.description ? "<em>" + t.description + "</em></div>": "")
},
styleItem: function(t, e, i) {
"offline" === t.data("entry").status ? t.removeClass("online").addClass("offline disabled") : t.removeClass("offline disabled").addClass("online")
}
})
},
getHeight: function() {
return this.$form.height()
}
})
}

...全文
542 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
上海程序员3 2017-06-19
  • 打赏
  • 举报
回复
直接 document.getElementById(”customer-chat-login-mail“).value="默认值" 这样子不行吗?

87,990

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧