Hi all,
I have an table with set rows.The column price is editable.Now how do i validate this price table cells in after rendering function so that just as and when user inputs wrong characters in these price cells error is thrown(example: as soon as user types "%" in these error needs to be raised)
validation condition
- max two decimal place allowed
- This is the maximum value possible 123456789011.00(11 digits plus 2 decimal value)
- Either , or . is allowed example 12.33 also 12,33
I know we need to use regexp for this validation but i am not sure how to point to the table cells as and when user enters somethings to check the same in onAfterRendering function
This is the code in onAfterRendering for other normal input field.so as user enters spl characters the error is raised.i want to implement the similar for the table cells
onAfterRendering: function() {
this.getView().byId("idno").attachBrowserEvent("keypress",
function(event){
event.stopImmediatePropagation();
var key1 = String.fromCharCode(!event.charCode ? event.which : event.charCode);
key = key1.trim();
key = key1.replace(/\s+/g, '');
if ((key != "") || (key != undefined)){
if (/^[a-zA-Z0-9- ]*$/.test(key) == false)
{
sap.m.MessageToast.show("Special characters not allowed");
event.preventDefault();
event.stopPropagation();
return false;
}
}
}
);
}