我正在使用下面的代碼來驗證TextField是否爲空或0,然後向它添加一個錯誤類以給它一個背景顏色。如何驗證Ember選擇列表?
我有另一個隱藏的文本框,並且根據在Ember.Select中選擇的內容設置了一個值,如果沒有選擇一個值如何最好爲select添加/更改錯誤類?
App.NumField = Ember.TextField.extend({
required: function() {
var valid = /^[1-9][0-9]*$/.test(this.get('value'));
return valid
}.property('value'),
classNameBindings: 'required:notreq:req'
});
{{view App.NumField valueBinding="type"}}
{{view Ember.Select contentBinding="App.Type" optionValuePath="content.id" optionLabelPath="content.type" valueBinding="type" prompt="Please select a type"}}
感謝您的任何建議。