3

I have a custom filed with number datatype and I have a requirement the the field should always start with 304050 and I have to write a condition that it must always contain 16 digits.

Is this posible?

Can someone help me with this?

4
  • Have you tried using validation rules?
    – Saroj Bera
    Commented Jul 10, 2015 at 9:10
  • I tried but i am not able to get it right Commented Jul 10, 2015 at 9:17
  • Ankita, you would paste your code here for better help.
    – Ashwani
    Commented Jul 10, 2015 at 9:24
  • NOT(REGEX(Card_Number__c, "\\D*?(\\d\\D*?){16}")) This is working now .. now i have to make sure that it always starts with 304050 Commented Jul 10, 2015 at 9:30

2 Answers 2

4

Ashwini's answer is correct with small change......

OR 
( 
LEFT(TEXT(field__c),6) != '304050', 
LEN(TEXT(field__c)) != 16 
) 
1

You can try something similar like this in validation rule using three functions (OR, LEFT, LEN):

OR 
    (
      (LEFT(field__c,6) != '304050',
      LEN(field__c) != 16
    )

Solution is for your hint purpose. may not be 100% correct.

1
  • Thanks..this is working if i have a text field ..but i have a number field and i cannot risk user entering text after 304050 Commented Jul 10, 2015 at 9:37

You must log in to answer this question.

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