Skip to Content
author's profile photo Former Member
Former Member

sap.m.Input change event is triggered when clicking on CheckBox

I have two controls in my page i.e. sap.m.Input and sap.m.CheckBox. There is a change event attached to input field which gives an error bar if input text is not matched with the regex. This change event is triggered on clicking out of focus of the input field. Clicking on checkbox will hide this input and show a third control. Now if i enter something in input field which will not match regex and click on checkbox, It is triggering changeEvent of Input and not even selecting the checkbox. I tried many things like checking in change event whether checkbox is ticked or not, attached a click event on checkbox but no solution. Please help me so that i will be able to determine the click on checkbox if the current focus is on input field.

Here is an example at jsbin.

var textInput = new sap.m.Text({text:"Area:"})
var inputField =new sap.m.Input("inptId",{



var select  = new sap.m.Select("select",
                                items:[new sap.ui.core.Item({text:"India"}),
                                      new sap.ui.core.Item({text:"US"}),
                                       new sap.ui.core.Item({text:"UK"})
var hBox = new sap.m.HBox({items:[textInput,inputField,select]})

  var bar = new sap.m.Bar("barId",{
    contentMiddle:new sap.m.Text({text:"Error"})

  var chkBox = new sap.m.CheckBox("chkBxId",{
  text:"Select from dropdown",
    var selected = oEvent.getParameters().selected;
var vBox = new sap.m.VBox({

Here error will be thrown if input text contains @ and change event is triggered.

Add comment
10|10000 characters needed characters exceeded

1 Answer

  • Posted on Jun 07, 2017 at 09:21 AM

    write your logic in keypress event instead of change event, as below:

    inputField.attachBrowserEvent("keypress", function(oEvent) {

    above code triggers as soon as you enter any key in input field.

    Add comment
    10|10000 characters needed characters exceeded