Connecting Tech Pros Worldwide Help | Site Map

Javascript validation for wildcard in string

Newbie
 
Join Date: Sep 2009
Posts: 2
#1: Sep 17 '09
Hi,
I am new to javascript, I need your help in javascript validation of a string.
string of length 6,
last 4 characters can be padded with "8" while entering.
valid strings are
ZJJL74
ZJJL7*
ZJJL**
ZJJ***
ZJ****

Invalid strings are
ZJ*L74
ZJJ*7*
*JJL**
Z*****
*****4
this means * cannot be entered in the middle,
it can be entered only at the end maximum up to last 4 characters.
please provide the solution ASAP, will be very grateful
RamananKalirajan's Avatar
Needs Regular Fix
 
Join Date: Mar 2008
Location: Chennai - India
Posts: 348
#2: Sep 17 '09

re: Javascript validation for wildcard in string


try using indexOf() function that will give you the solution what you are looking for...

Thanks and Regards
Ramanan Kalirajan
Newbie
 
Join Date: Sep 2009
Posts: 2
#3: Sep 17 '09

re: Javascript validation for wildcard in string


can you please give the function with an example
Dormilich's Avatar
Moderator
 
Join Date: Aug 2008
Location: Leipzig, Germany
Posts: 3,629
#4: Sep 17 '09

re: Javascript validation for wildcard in string


why is everyone always wanting the code?

you could also try an RegExp. (you’ll probably need the look-ahead and/or look-before groups (?=, ?!, ?<=, ?<!))
Reply