Visualforce: apex:inputText – restrict input to numbers only

How to restrict apex:inputText to take number values only?


One way you could make this work is HTML5-ifying your Visualforce page and use <apex:input type="number" /> instead of apex:inputText.

Otherwise, you could implement some javascript validation or send it back to your controller and do the validation in Apex.

Note: To HTML5-ify your page, the easiest way is using the page
element with the docType attribute <apex:page docType="html-5.0">.


Source : Link , Question Author : justasd , Answer Author : James Loghry

Leave a Comment