1

I have a visual force page in which I have a field to accept decimal values. I can restrict the user from entering 0.0 and null values, but I cant do the same for '' (Empty String). Is there any method that would come in handy to solve my problem?

  • That can be done on server and client side too. Are you using VF or HTML tags for the field? And how are you preventing the user from entering 0.0 and null currently? Can you please post some code? – Boris Bachovski Aug 13 '13 at 5:40
  • im doing the validation in the controller . like if(amount == 0.00 || amount == null){ ErrorMsg = 'AMOUNT REQUIRED' +'<br/>'; } – Aravind30790 Aug 13 '13 at 5:46
3

I would use Javascript :

<input type="text" onkeyup="this.value = this.value.replace(/[^\d.]/g, '');" />
| improve this answer | |

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.