Javascript validation for wildcard in string

September 16, 2009 at 22:42:13
Specs: Windows XP, 2 GB
hi,
All
I want a javascript function to validate a string with wild characters,
string is os lenght 6.
Last 4 characters can be padded with "*",
valid string are
ZJJL74
ZJJL7*
ZJJL**
ZJJ***
ZJ****
Invalid string are
ZJ*L74
ZJJ*7*
*JJL**
Z*****
*****4

this means * cannot come in the middle.
it can be only at the end..
Please provide the solution ASAP, I will be very grateful


See More: Javascript validation for wildcard in string

Report •


#1
September 16, 2009 at 23:37:20
prateeksha, try using "?" for a single character and save "*" for multiples? According to the programming conventions I learned, "*" had to come at the end of a string as your machine wouldn't parse past it.
HTH.
Ed in Texas.

Report •

#2
September 16, 2009 at 23:40:12
thanks for the reply but can you give an example

Report •

#3
September 18, 2009 at 02:05:02
prateeksha, I was told "ZJJ*7*" was invalid while "ZJJ?7*" was valid. Apply? Dunno.
HTH.
Ed in Texas.

Report •

Related Solutions

#4
September 18, 2009 at 04:22:33
thanks a lot for ur response.. i completed it using indexOf function..

Report •


Ask Question