Quantcast
Viewing all articles
Browse latest Browse all 2067

sap.m.Input with Float type

Hello,

My requirement is to have a textbox that can accept only floating point numbers up to two decimals only.

 

How to fix below problems:

  1. I am unable to type anything like 10.01 but I am able to type 10.10.
  2. When I start typing 66.66 -> after this if you press 6 one more time it starts rounding off the last decimal. My requirement is not to allow the user to type anything else after last two decimal digits.

 

Below is my code:

 

<!DOCTYPE html><html><head><script src="https://openui5.hana.ondemand.com/resources/sap-ui-core.js" id="sap-ui-bootstrap" data-sap-ui-theme="sap_bluecrystal" data-sap-ui-libs="sap.m"></script>  <meta charset="utf-8">  <meta name="viewport" content="width=device-width">  <title>JS Bin</title></head><body>  <div id="content"/><script>  sap.ui.getCore().setModel(new sap.ui.model.json.JSONModel(),"myModel");  sap.ui.getCore().getModel("myModel").setProperty("/Amount")  var textbox = new sap.m.Input({    valueLiveUpdate:true,    type:"Number",  }).placeAt("content");  textbox.bindProperty("value",{            path:"myModel>/Amount",  type:new sap.ui.model.type.Float({  minIntegerDigits:1,         maxFractionDigits:2,         groupingEnabled:false  },  {      minimum:1,      maximum:2000     })  });
textbox.attachValidationError(function(e){    e.getParameter("element").setValueState("Error");    e.getParameter("element").setValueStateText(e.getParameter("message"));  });
textbox.attachParseError(function(e){    e.getParameter("element").setValueState("Error");    e.getParameter("element").setValueStateText(e.getParameter("message"));  });
textbox.attachFormatError(function(e){    e.getParameter("element").setValueState("Error");    e.getParameter("element").setValueStateText(e.getParameter("message"));  });
textbox.attachValidationSuccess(function(e){    e.getParameter("element").setValueState("Success");  });  </script></body></html>

Viewing all articles
Browse latest Browse all 2067

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>