Announcements
No record found.
How to restrict the text field to accept only numbers with minimum 9 digits and maximum 14 digits. How can i achieve this with Java script code
Hi Partner,
Please refer to the following code.
function checkNumberDigits(executionContext){ var formContext=executionContext.getFormContext(); var textValue=formContext.getAttribute("fieldNaame").getValue(); //check if the text value is number type if (!isNaN(textValue)) { var length=textValue.length; if(length>14||length Add this code in your field onChange event. Regards, Leo
Add this code in your field onChange event.
Regards,
Leo
Hi Leo thanks for your response, the code is working well but accepting alphabets too
HI,
function checkNumberDigits(executionContext) { var formContext = executionContext.getFormContext(); var textValue = formContext.getAttribute("fieldNaame").getValue(); //check if the text value is number type if (!isNaN(textValue)) { var length = textValue.length; if (length > 14 || length < 9) { alert("Number should with minimum 9 digits and maximum 14 digits!") } } var patt = new RegExp("^[0-9]*$"); if (!patt.test(textValue)) { alert("Only Numbers/Digits between 0-9 allowed"); } }
You should add this code on save event to prevent user to save the record. If you go with onchange event then only popup will be displayed but user will be able to save the record.
docs.microsoft.com/.../preventdefault
Hi Bipin, thanks for your response the above code works well for number of digits and accept only numbers, this is perfect for Onchange event.
Did you try my solution in your instance?
If my answer also helped you, please mark my answer as verified.
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.
Congratulations to our 2026 Super Stars!
We are thrilled to have these Champions in our Community!
These are the community rock stars!
Stay up to date on forum activity by subscribing.
ManoVerse 182 Super User 2026 Season 1
11manish 123
CU11031447-0 100