I have two fields checkbox and a textbox field, if the user clicks on the checkbox checked than I want to enable the textbox field otherwise remain disabled. I'm not sure if this is possible using validation rule and I'm working on a salesforce standard page.


It sounds like your requirement can be stated:

If Checkbox__c is checked, require TextField__c be populated. If Checkbox__c is unchecked, require TextField__c be empty.

You can validate as follows:

Checkbox__c == ISBLANK(TextField__c)

You will still need some user training on the layout itself (it won't enable/disable the input element), but the errors should be self evident to them.

| improve this answer | |
  • I have tried and does not seems to work, its ignored and my validation is active – Nick Kahn May 10 '16 at 22:30
  • It works for me...you're using standard page layout? POC in my sandbox allows checked + input, checked + blank, and unchecked + blank, but errors for unchecked + input. – Adrian Larson May 10 '16 at 22:38
  • very strange that its working for you and yes I'm using standard page layout and i checked the checkbox and my textfield is empty and when i click on save it does save successfully. – Nick Kahn May 11 '16 at 0:55
  • You want to block text populated and box not checked, correct? @Nick – Adrian Larson May 11 '16 at 0:55
  • so I have checkbox and a textfield: if the user checked the checkbox and try to save the page then error should fire asking the user to enter the textfield since checkbox is checked and if the user unchecked the checkbox then textfield should be blank/clear/empty automatically and if not possible clearing the textfield auto then fire-up the error asking user to clear the textfield. - hope this clears up – Nick Kahn May 11 '16 at 1:08

You can't enable/disable textbox fields in a salesforce standard page while entering data. You can do this for a picklist fields using field dependency feature.

One workaround i can suggest if you want to achieve this after the page is saved, you can do that using RecordTypes and Pagelayout.

Create a record type called ‘Lock’, then a Page Layout with the textbox field as Read-Only. Then build a workflow to change the record type (and assigned page layout) when the checkbox is ticked.

Another workaround is as suggested by @Adrian, to use validation rule to throw error is the checkbox is not checked and the text field have some value.

Hope it helps.

| 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.