0
<apex:inputField value="{!expence}" styleClass="slds-input inputWidth August" 
                                            onchange="updateAfterBlur();" />

Input - 12.22222 (Decimal value should not increase the length 5 such as .22222) User should not be able to enter more then 5 digits after decimal and as many number user wants before decimal. Only the condition is for after decimal.

To be done by javascript.

  • what you have tried so far? – Santanu Boral Jul 26 '18 at 9:04
  • I tried with key codes and i can work with that but my client doesnt want the key codes to be used so i need a different solution and it is mandate to use apex:inputField – SHAAN Jul 26 '18 at 9:22
  • You can use number field and put decimal place 5 and you can create validation rule if after decimal limit is more than 5 then show the error message. – cloudZigZag Jul 26 '18 at 11:00
0

Salesforce recommends lesser javascript on visualforce though... Whether you want to convert the number in two decimal places you may use the function toFixed(value) Method Reference. However, you want to restrict the values when users type. Please try using the following code

var check = function(x) {
  var y = x.value;
  x.value = (y.indexOf(".") >= 0) ? (y.substr(0, y.indexOf(".")) + 
  y.substr(y.indexOf("."), 6)) : y;
}

the number 6 defines how many values after the decimal

0

you can use the following format

<apex:outputtext value="{0,Number,0.00000}" >
   <apex:param value="{!expence}"/>
 </apex:outputtext>
  • 1
    The question is about <apex:inputField> rather than <apex:outputField> or outputText; this doesn't really answer the question. – David Reed Jul 26 '18 at 11:48
  • No error should be shown is the criteria well i got the solution thanks....@israel – SHAAN Jul 26 '18 at 12:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.