cancel
Showing results for 
Search instead for 
Did you mean: 

sap.m.combobox validation in case of jaavscript code

former_member338801
Participant
0 Kudos
135

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
 })
 ]

manju537449
Participant
0 Kudos

hi,

Can you please tell what validation you need to put so that it will be more clear to answer.

Regards,

Manjunatha Devadiga

former_member338801
Participant
0 Kudos

Thanks Manju for asking.

Actually user can enter free text data right now. We have stop free text data that is not part of dropdown reasons similarly for Datepicker if you remove all the data it won't validate right now. Let me know for any further details.

former_member338801
Participant
0 Kudos

..........

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