• Larry Van Cantfort
  • NEWBIE
  • 10 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 3
    Replies
I am trying to make a credit card field required when a picklist value is NOT Checking (as in checking account. The other picklist items are credit cards) and then check to make sure the credit card is numbers and a length of 16 for Visa and Mastercard or 15 if AMEX. I have two problems with my validation rule. Problem one, does not make the credit card field required when the picklist is Checking. Problem two, the credit card field accepts letters and numbers. I am new to validation rules and even newer to regex. Any ideas?

AND( 
NOT(ISPICKVAL( Method__c , "Checking")), 
( Not(REGEX( Credit_Card__c , "(\\d{4}-){3}\\d{3}|\\d{15}" )) 
&& NOT( REGEX( Credit_Card__c ,"(\\d{4}-){3}\\d{4}|\\d{16}")) 

)
I am trying to check to see if a field has only numbers in it. It can also be left blank. The regex formula that I have written accepts both letters and numbers and I cannot figure out what I am doing wrong. I am new to regex so please be kind.

The validation rule is:
AND( 
ISBLANK(Checking_Account_Number__c), 
NOT (REGEX(Checking_Account_Number__c, "(//[0-9]+)")) 
)

Thanks for any help.
I am trying to make a credit card field required when a picklist value is NOT Checking (as in checking account. The other picklist items are credit cards) and then check to make sure the credit card is numbers and a length of 16 for Visa and Mastercard or 15 if AMEX. I have two problems with my validation rule. Problem one, does not make the credit card field required when the picklist is Checking. Problem two, the credit card field accepts letters and numbers. I am new to validation rules and even newer to regex. Any ideas?

AND( 
NOT(ISPICKVAL( Method__c , "Checking")), 
( Not(REGEX( Credit_Card__c , "(\\d{4}-){3}\\d{3}|\\d{15}" )) 
&& NOT( REGEX( Credit_Card__c ,"(\\d{4}-){3}\\d{4}|\\d{16}")) 

)
I am trying to check to see if a field has only numbers in it. It can also be left blank. The regex formula that I have written accepts both letters and numbers and I cannot figure out what I am doing wrong. I am new to regex so please be kind.

The validation rule is:
AND( 
ISBLANK(Checking_Account_Number__c), 
NOT (REGEX(Checking_Account_Number__c, "(//[0-9]+)")) 
)

Thanks for any help.