<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
<title>SAPUI5 Accordion</title>
<script id="sap-ui-bootstrap"
src="https://sapui5.hana.ondemand.com/resources/sap-ui-core.js"
data-sap-ui-theme="sap_bluecrystal"
data-sap-ui-libs="sap.ui.commons"></script>
<script>
//var integerPattern = (/^-?\d*(\.\d+)?$/);
var phoneNOTextField= new sap.ui.commons.TextField({
id:"phoneNOTextField",
width:"100px"
/*onKeyup:function(evt){
evt = (evt) ? evt : window.event;
var charCode = (evt.which) ? evt.which : evt.keyCode;
if (charCode > 31 && (charCode < 48 || charCode > 57))
{
sap.ui.getCore().byId("phoneNOTextField").setValue="";
}*/
});
phoneNOTextField.attachBrowserEvent("keyup",function(evt){
var charCode = (evt.which) ? evt.which : event.keyCode
var phoneNOValue = evt.target.value;
if (charCode > 31 && (charCode < 48 || charCode > 57))
//if(!(phoneNOValue.match(integerPattern)))
{
evt.target.value="";
}
});
phoneNOTextField.placeAt("div1");
</script>
</head>
<body class="sapUiBody">
<div id="div1"></div>
</body>
</html>
this is d code i am using
i used keycode,keypress,keyup as events for the function
works well but it displys letters and then empties the field
my requirement is it should display and take only numbers
please help