/    Sign up×
Community /Pin to ProfileBookmark

form validation: a newby question …

Hi,

I am trying to establish a form validation upon pressing submit. All is fine so far except a little problem. For one entry, I would like to have people to enter something like “BB0000000” where only the digits (“0”) can vary. I just do not know how to perform such a validation, meaning how to check that the input starts with “BB” and is followed by seven digits… Can you help me on this one ?

So far, I have this but I figure it cannot help me here…

[code=html] if (x.blabla.value == “”) {
alert (“Please, select a name!”);[/code]

thanks in advance !

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@mjdamatoJul 10.2007 — <i>
</i> regex = /^BB(d{7})$/;
if (!regex.test(x.blabla.value)) {
alert ("Please, select a name!");
}
Copy linkTweet thisAlerts:
@patimagesauthorJul 10.2007 — works great !!!!!!!!!

thank you sooooo mmmuuuuccccchhhhhhhhhhhh!
×

Success!

Help @patimages spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...