RE: preventing event from happening on attached onkeypress function
Hi okank,
I am not sure if you would be able to get the context abd return false but you can achieve this requirement by following script. I have added this on account number field of account entity-
============
function AttachKeyPressValidation() {
var keyPressFcn = function () {
var userInput = Xrm.Page.getControl("accountnumber").getValue();
if (isNaN(userInput)) {
var f = userInput.substring(0, userInput.length);
Xrm.Page.getAttribute("accountnumber").setValue(f);
}
};
Xrm.Page.getControl("accountnumber").addOnKeyPress(keyPressFcn);
}
================
Hope this helps.