Notifications
Announcements
No record found.
How to limit Textbox to enter 5 digits numerics only not alphabets using Javascript mscrm 2016?
*This post is locked for comments
Hi ,
Try with this , below code should work but I would suggest replace the the keypress method with dynamics CRM OOB method addOnKeyPress .
https://community.dynamics.com/crm/b/mscrmcustomization/archive/2016/10/24/keypress-methods-in-ms-crm-2016
//Add the code in web resource and load the webresource in the page $("#new_Fax").keypress(function (event) { var charCode = event.keyCode; var obj = event.target; if (charCode < 48 || charCode > 57) return false; else return true; }); //Register the function in onchange of field function OnChangeFax() { var FaxNo = Xrm.Page.getAttribute("new_Fax").getValue(); if (FaxNo != null && FaxNo != undefined) { if (FaxNo.length < 5) { Xrm.Page.getControl("new_Fax").setNotification("Fax should be atleast 5 digits.", 'ERROR', 123); Xrm.Page.getAttribute("new_Fax").setValue(null); } else { Xrm.Page.getControl("new_Fax").clearNotification(); } } }
Instead of creating simple textbox and limiting it using javascript, I would recommend you to create whole number field with following settings:
Hi,
whay don't you use the OOTB field type und choose number type and limit to 5 digits?
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
SA-08121319-0 4
Calum MacFarlane 4
Alex Fun Wei Jie 2