cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

sap.m.combobox validation in case of jaavscript code

Former Member
0 Likes
550

Hi Experts,

How to put validation on combo box and Datepicker written in a java script view?

  var myJSON = {
 Data: [{
 Reason: "Reason1"
 }, {
 Reason: "Reason2"
 }, {
 Reason: "Reason 3"
 }, {
 Reason: "Reason4"
 }]
 }

if (!this.dialog) {
 var dialog = new Dialog({
 title: 'Say to reject',
 width: "50%",
 type: 'Message',
 content: [
 new Label({
 width: '50%',
 text: 'Reason of rejectione?',
 labelFor: 'rejectDialogTextarea'
 }),
 new sap.m.ComboBox('combobox', {
 width: '50%',
 items: {
 path: "/Data",
 template: oItem
 }
 }),
 new Label({
 width: '50%',
 text: 'Date of rejection?',
 labelFor: 'rejectDialogTextarea'
 }),
 new sap.m.DatePicker("datePicker", {
 width: '50%',
 valueFormat: "dd-MM-yyyy",
 displayFormat: "MM-dd-yyyy",
 value: datepickerdate
 })
 ]

Accepted Solutions (0)

Answers (1)

Answers (1)

manju537449
Participant

Hi,

You can add Selection change event for dropdown and change event for date picker.

var myJSON ={Data:[{
 Reason:"Reason1"},{
 Reason:"Reason2"},{
 Reason:"Reason 3"},{
 Reason:"Reason4"}]}if(!this.dialog){
 var dialog=newDialog({title:'Say to reject',width:"50%",type:'Message',
 content:[new Label({width:'50%',text:'Reason of rejectione?',
 labelFor:'rejectDialogTextarea'}),
  newsap.m.ComboBox('combobox',{width:'50%',
 items:{
 path:"/Data",
 template: oItem
 },
 selectionChange: function (){                         
              var value = sap.ui.getCore().getControl('numCombo').getKey();
                     //Here you can put your validation code
            }
}),new Label({width:'50%',text:'Date of rejection?',
 labelFor:'rejectDialogTextarea'}),newsap.m.DatePicker("datePicker", {width:'50%',
 valueFormat:"dd-MM-yyyy",
 displayFormat:"MM-dd-yyyy",value: datepickerdate,

change:function(evt){

var date = evt.oSource.mProperties.dateValue;
//Add Validationcode here for date
}
 })

Regards,

Manjunatha Devadiga

Ask a Question