0

I do not find anyway that you can validate a valid url when the user enters in the standard page so I come up with this validation and I need little help to fix it.

I'm using BEGINS to see if the url starts with HTTP or HTTPs

My scenario is,

--Validation should ONLY fire when Attachment == false
-- When the users enters the URL make sure the URL starts with http:// or https://

Attempted:

if(Attachment__c == false && NOT(ISBLANK(url__c), true (BEGINS(URL__c, "https://")))
3
  • try with this IF(AND(Attachment__c == false, OR(ISBLANK(url__c), NOT(BEGINS(URL__c, "https://")), NOT(BEGINS(URL__c, "http://")))), true, false )
    – Ratan Paul
    Commented May 9, 2016 at 17:10
  • didn't work, even though after entering the url starting with http:// still thinks its not a valid url
    – Nick
    Commented May 9, 2016 at 17:23
  • downvoters: care to explain why you think you should down vote?
    – Nick
    Commented May 9, 2016 at 22:05

2 Answers 2

3

Try this:

AND(
    Attachment__c == false,
    NOT(ISBLANK(URL__c)),
    NOT(BEGINS(URL__c, "https://")),
    NOT(BEGINS(URL__c, "http://"))
)

You don't typically need an IF statement for a validation rule. A validation rule is basically the conditional portion of the IF statement and returns true or false based on the conditional. True means display the error, false means do not display the error.

2
  • Perhaps worth mentioning there are other valid protocols, e.g. ftp://, etc.
    – Adrian Larson
    Commented May 9, 2016 at 18:31
  • 1
    To add to @AdrianLarson, I wanted to note that this will allow http://&5# or http://mike, neither of which are valid URLs. Commented May 10, 2016 at 18:16
0

Perhaps, only validation for the URL starting with "http" would be enough:

NOT(
 OR(Attachment__c,
 ISBLANK(URL__c),
 BEGINS(LOWER(URL__c, "http"))
)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .