1

I am trying to set a validation rule to check if a field contains only digits

Tried this condition : !ISNUMBER(myfield__c)

But the user can type 123.123

How to check that each char of the field content is a digit ?

  • 1
    This seems like it would only be necessary on text fields that you're using to capture numeric input on. Is there a particular reason why you're not using a Number field here? That would largely (if not completely) remove the need for a validation rule in the first place. – Derek F Jun 7 '17 at 13:58
  • 1
    @DerekF by using a number type field, if the user input 00001, SF will display it as 1 , in our case each digit is important ... – benahm Jun 7 '17 at 14:05
2

Solved it by using the REGEX function

!REGEX(myfield__c,"[0-9]*")
| improve this answer | |
  • You should go ahead an accept your own answer @benaham. (I won't repeat the "two problems" joke) – John Thompson Jun 7 '17 at 14:01
  • 1
    @JohnThompson yep in two days, cause there is a validation rule implemented on StackExchange that prevent me from doing it right away :D – benahm Jun 7 '17 at 14:07
  • 1
    What about the digit 0? – martin Jun 7 '17 at 14:25

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.