By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,460 Members | 1,095 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,460 IT Pros & Developers. It's quick & easy.

Javascript validation for wildcard in string

P: 2
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
Sep 17 '09 #1
Share this Question
Share on Google+
3 Replies


RamananKalirajan
100+
P: 607
try using indexOf() function that will give you the solution what you are looking for...

Thanks and Regards
Ramanan Kalirajan
Sep 17 '09 #2

P: 2
can you please give the function with an example
Sep 17 '09 #3

Dormilich
Expert Mod 5K+
P: 8,639
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 (?=, ?!, ?<=, ?<!))
Sep 17 '09 #4

Post your reply

Sign in to post your reply or Sign up for a free account.