I have a requirement where field value should be restricted to 6 and out of which first two should be alphabet and last 4 to be numeric. In the alphabet part input can only be LP or DP.

priya130
Kilo Contributor

Hi All,

I have a requirement where field value should be restricted to 6 and out of which first two should be alphabet and last 4 to be numeric. In the alphabet part input can only be LP or DP.

eg. LP1000(any 4numeric value is ok) and DP8765

no restriction is there for numeric part, it can be any numeric value. Alphabet should be LP or DP. Can anyone help me for writing regex for this ?

 

Thanks in Advance

1 ACCEPTED SOLUTION

Murthy Ch
Giga Sage

Hi Priya,

If you are doing this on catalog item, Create a regex in variable validation regex table.

And use this logic:

^[LP|DP]{2}[0-9]{4}$

And in the variable attributes set this:

max_length=6 //so that user cannot enter more than 6 letters

(=tested)

Hope it helps.

 

Thanks,

Murthy

Thanks,
Murthy

View solution in original post

5 REPLIES 5

Glad to help:)

Thanks,
Murthy