/    Sign up×
Community /Pin to ProfileBookmark

conditional validation

This has been driving me crazy for about a month now.

I have an hta file that I created for my Job. There is a field called “youruid” which is where the agents have to place their User ID. All User ID’s are in a specific format.

Currently I am using this

function uidcheck()
{
var uidpopup = “Your UID”;
if (youruid.value.length<6) {
youruid.disabled=false
alert (uidpopup + ” is invalid”)
youruid.value=””
document.getElementById(“youruid”).focus();
}
else {
youruid.disabled=true
return false;
document.getElementById(“ban”).focus();
}
}

Its working okay but I really want the field to be validated with a format.
The IDs are in this format aa000[a or 0] two characters (not case sensitive) then either 4 numbers or 3 numbers then another character.

I believe the format is [a-zA-Z]{2}d{4} for for numbers

How can I make the function validate to make sure that it is in this format?

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@ZeroKilledMay 08.2009 — use the [b]test[/b] method to check if the regular expression match the value. <i>
</i>if (youruid.value.length&lt;6 || !/^[a-z]{2}d{3,4}[a-z]$/i.test(youruid.value)) {
Copy linkTweet thisAlerts:
@dumbestcrayonauthorMay 08.2009 — THANK YOU SO MUCH!!!


I changed it because your ending didn't work, it only allowed aa000a but all I needed was the script to use this code. Now I got it

Thank you again


Heres the code I used


[CODE]if (youruid.value.length<6 || !/^[a-z]{2}d{3}[a-z0-9]$/i.test(youruid.value)) {[/CODE]
×

Success!

Help @dumbestcrayon 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 5.18,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...