R
E
S
O
U
R
C
E
S
       Question Index      Products & Services      Contact Us      Links


WebHatchers will design & develop your site for you.
_______________________

Website Menu Heaven: side or top popup menus, buttons, image rotators, navbars, tons more.
_______________________

Send us your questions and wittiest comments.
_______________________

Report errors on our site.
_______________________

Share your neatest DHTML examples with us; we may publish them.
_______________________


_______________________

      QUESTION INDEX      

Question Index
Browser Insanity
JavaScript
Animation
Buttons and Menus
CSS and HTML
PHP
Personal Status Boards
Content Management
   Systems
Article Content
   Management Systems
Website Directory
   CMS Systems
Photo Gallery CMS
Forum CMS

 INFORMATIVE ARTICLES 

Menus-and-Buttons-
Part-I.htm


Menus-and-Buttons-
Part-II.htm


Change-Div-Size-Color-
and-Location-with-the-
W3C-DOM.htm


Bouncing-Ball-Animation-
with-the-W3C-DOM.htm


Style-Changes-with-the-
W3C-DOM.htm


Animation-with-the-
W3C-DOM.htm


Window-Play-and-Some-
Important-DOM-Methods.htm


Using-getElementsByTagName
-and-getElementsByName.htm


The-CSS-Resources-Intro-
Page.htm


Convert-Word-Files-to-HTML-
and-Install-Editor2-to-
Use-Instead-of-NotePad.htm


CSS-Issues.htm

What Are Fifteen Simple Methods of Doing Web-Page Pop-ups?

Security levels from Javascript and PHP input filtering

What is a regular expression general input validator?

What is a regular expression user name validator?

What is a regular expression password validator?

What is a regular expression email validator?

What is a regular expression URL validator?

How can I convert a Javascript array to a PHP array?

How can I Dynamically Create Input Boxes with Validation?

How do I use JavaScript Object Notation (JSON) in PHP and JavaScript to convert strings and arrays from PHP to JavaScript?

How do I add html to a web page with JavaScript, PHP or ssi includes?

How do I add html to a web page with JavaScript includes?


PHP

How do you put PHP variables in URL and link text?

What is PHP Code for Multiple PSB Hosts?

What is Registration PHP Code for Multiple PSB Hosts?

What is Registration PHP Code for Multiple PSB Hosts with a captcha?

What is Administrator PHP Code for Multiple PSB Hosts?

What's the PHP code for a script for a PSB?

What's the PHP code for a script for PSB updating?

What's the PHP code for a script if you forgot your user name?

What's the PHP code for a script if you forgot your password?

What's the PHP code for a script to change a member's email address?

What's the PHP code for a script to connect to a MySQL database?

What's the PHP code for a script to close a member's account?

What's the PHP code for a script to edit group member?

What's the PHP code for a script to add group member?

What's the PHP code for a script to reset a MySQL table's data to its original?

What's the PHP code for a script to edit a MySQL table's data?

What's the PHP code for a script to change a username?

What's the PHP code for a script to change a password?

What's the PHP code for a script to delete group member?

What's the PHP code for a script to view membership data?

What's the PHP code for a script to change an administrator's password?

What's the PHP code for a script to logout?

What's the PHP code for a script to login?

Security levels from Javascript and PHP input filtering

Security levels and PHP

How can I convert a Javascript array to a PHP array?

What is PHP Code to Prevent Duplicate Data Input - Like User Names or Members?

What is PHP Code for PSB Status Update for Multiple PSB Hosts?

How do I sort 1 PHP array and have the other arrays sort in parallel to how the first array sorts?

How do I use JavaScript Object Notation (JSON) in PHP and JavaScript to convert strings and arrays from PHP to JavaScript?

How do you do PHP-to-JavaScript String Conversion with No JSON?

How do you Convert PHP String to JavaScript String?

How do you Post a JavaScript Array to a PHP Array?

How do you send a value to PHP using JavaScript?

Info on unwanted primary field auto-sorting

How can I do instant article font size, font family, and paragraph formatting with radio buttons?

How can I create custom HTML tags that are safer for MySQL databases?

How can I edit text from MySQL databases by using a textarea box?

How can I highlight matched search terms in a MySQL database table search?

How can I search using not only exact phrase matching but also a series of words to match in a MySQL database table search?

What's the code for an Ajax and PHP Based Input Filter?

Ajax and PHP Based Insult Auto-Completer

How can I use PHP and MySQL for Checking Key Codes to Allow Update to a New Software App Version?




Personal Status Boards (PSB™)

Standard Free PSB

PSB Pro Version

Social PSB

Social PSB Plus (with Email)

Business PSB

Business PSB Plus (with Email)

PSB demo

Social PSB demo

Business PSB demo

So what's all this PSB stuff about?

Chart comparing business status boards

PSB hosting diagram

PSB Licence Agreement




Article Content Management System

Content Management System Introduction

Content Management System—Article Navigation

Content Management System—Article Indexing

Content Management System—Article Editing

Content Management System—Article Searching

Content Management System—Article Deleting

Content Management System—Article Writing

Content Management System—Article Reading

What are the terms of use for our Article Content Management System?




Website Directory Content Management System

Website Directory Navigation

Website Directory—Delete Category

Website Directory—Delete URL

Website Directory—Add URL

Website Directory—Add Category

Website Directory—Directory Creating

Website Directory—View by Category (Demo Code)

Website Directory—View by URL (Demo Code)

Website Directory—View by Category (Demo)

Website Directory—View by URL (Demo)

Website Directory—View

Website Directory—View (Demo)




Photo Gallery Content Management System

Code for Photo Gallery Navigation

Code for Photo Gallery—View

Code for Photo Gallery—Create

Code for Photo Gallery—Add Category

Code for Photo Gallery—Delete Category

Code for Photo Gallery—Add Photo

Code for Photo Gallery—Delete Photo

Code for JavaScript Photo Gallery

JavaScript Photo Gallery




Forum Content Management System

Forum: home page

Forum: search

Forum: login

Forum: topic and replies viewing page

Forum: add topic to database

Forum: add reply to database

Forum: edit topic in database

Forum: create topic in database

Forum: delete topic in database

Forum: delete reply in database

Forum: delete user account in members table



Copyright © 2002 -
MCS Investments, Inc. sitemap

PSBs, social networking, social evolution, microcommunities, personal status boards
PSBs, social networking, business personal status boards
website design, ecommerce solutions
website menus, buttons, image rotators
Ez-Architect, home design software
the magic carpet and the cement wall, children's adventure book
the squirrel valley railroad, model railroad videos, model train dvds
the deep rock railroad, model railroad videos, model train dvds

Regular Expression Username Validators and a Random Username Generator

The source code for the Regular Expression Username Validator is at the bottom of the page. A discussion of what we did precedes the code. Just before that you'll find a link giving you the opportunity to try out the Regular Expression Username Validator. If you use either of the validators somewhere on the Net, please give us a dofollow backlink with link text: "Regular Expression Username Validator." If you use the random username generator somewhere on the Net, please give us a dofollow backlink with link text: "Random Username Generator". Thank you. Below, you'll see a grueling series of test Usernames we subjected our Regular Expression Username Validator to, followed by the results. First we will look at Usernames that validated, and our comments about the results. Then we will look at Usernames that did not validate, and our comments about why these were the correct results.

The Regular Expression Username Validator has 3 parts. If you use our code, you will want to choose which of the 2 validators you like best—or whether you like the random username generator better. The first validator tells them what characters are okay, and stops them after 12 characters are entered. Then it sends the input to a validator function and if any illegal characters were entered, it gives them an alert and says to try again by erasing their entry and keeping the focus in the input box. It does not fix the illegal input.

The second validator looks for bad input and fixes either too few characters or illegal characters by use of adding numbers to their input, or in place of bad characters. If the fixed username is acceptable, the user gets to accept it, and if not, the user gets to reject it.

The random username generator is simple—you input the number of characters you want in your username and it gives you a username of that length with randomly chosen uppercase or lowercase letters, or numbers, or _ characters.

THESE USERNAMES WILL VALIDATE:
JOEjoe uppercase is fine but a stronger username would have some of these as well: 0123456789_ so JOE_12_j88@ is much better
JOE_joe_Joe usernames with _ in them are fine too
_______ this is okay technically but is a terrible username because one cannot tell by looking at it how many underscores there are, and variety gives much more username strength
JJJJJJJJJJJ this is okay technically but is a terrible username because it's hard to count the letters, and variety gives much more username strength
qwerty123 this is too easy to guess
myusername this is also too easy to guess
asdfghjkl this is also too easy to guess since they are right in a row on the keyboard


THESE USERNAMES WILL NOT VALIDATE BECAUSE:
JOE_j too short
JOE.Joe dots are not allowed
JOE joe spaces are not allowed
joe_joe    even if the space is at the end of the input, spaces are not allowed
"JOE_joe" quotes are not allowed
JOE-joe hyphens are not allowed
<>?,./:;"'{[}]+=- none of these characters are allowed



The code below lets you test various Usernames to check what will or will not validate with the check() function. In the code, for testing we used: {alert("Username validated OK.");d.username.value='';d.username.focus();return false}} but when you actually use the code, change this alert code to simply {return true}}, and add an appropriate action in the form tag.

The code below also lets you test various Usernames to check what will or will not validate with the check_edit() function. Note that we did not allow more than 12 characters, so the code—if (l>12) {p=p.slice(0,12)}—where we slice off more than 12 characters is redundant, since the form does this already with maxLength="12" in the input box. In the code, for testing we used: if (r==true){alert("Accepted");d.username.value='';d.username.focus();}else{alert("It's rejected—try again.");d.username.value='';d.username.focus();}return false;} but when you actually use the code, change this code to simply if (r==true){alert("Accepted");return true;}else{alert("It's rejected—try again.");d.username.value='';d.username.focus();}return false;}, and add an appropriate action in the form tag.

The code below also lets you generate various Usernames to check what kinds of Usernames you'll get with the random username generator in the check_number() function. Note that we did not allow more than 12 characters or less than 6 and if your input text is not a number, the JavaScript isNaN() function will detect it and you'll get a 6 in its place. In the code, for testing we used: if (r==true){alert ("Accepted");
d.usernamesize.value='';d.username.value='';d.usernamesize.focus();}else{alert("It's rejected—try again.");
d.usernamesize.value='';d.username.value='';d.usernamesize.focus();}return false;}
but when you actually use the code, change this code to simply if (r==true){alert("Accepted");return true;}else{alert("It's rejected—try again.");d.usernamesize.value='';d.username.value='';d.usernamesize.focus();}return false;}, and add an appropriate action in the form tag. The username is in the variable a.

Now let's look at the regular expressions we used:

The check() function: The /^[A-Za-z0-9_]{6,12}$/; is the whole regular expression. This gets put into the variable ck_username. The / at the start and end match a word boundary. The ^ says to match right after the start of the string (inputted URL). The $ at the end says to match right before the end of the string (inputted URL). The []s are a "character class", also called "character set", with which you can tell the regex engine to match only one out of several characters. The {} brackets mean {min,max}, i.e., the least to the most letter characters that will match the input string. The {6,12} mean if the input string has 0, 1, 2, 3, 4, 5 or more than 12 characters, the match will fail. (Many sites require a minimum of 6 characters for usernames.) In the bracket-bounded character class, A-Z is a range meaning all uppercase letters. And a-z means all lowercase letters. And 0-9 means all digits. \d would mean the same but is harder to read. The expression d=document.form is putting the document's 1st form in a convenient variable. The code if (document.form.username.value.search(ck_username)==-1) searches the form value just input for the regular expression pattern in the varible referenced in the (), which is ck_username. The d.username.value='' code means emptying the form value after bad input. The d.username.focus() code means keeping the cursor in the input box for a do-over. The return false code means don't submit the input string, just like a return true would mean the string validated so submit it. This script is a test script, as mentioned above, so we didn't want submitting regardless of validation, since then it would reload the page, since that is how the browser interprets the action=" " in the form tag.

The check_edit() function: First we stick 123456 in the z variable. Then we check the length of the input string and if it is under 6, we slice off a chunk of the z string and add it to their input, giving us the required 6 characters. If they inputted more than 12 characters, we slice it off until it is 12 long—our maximum. Our p=p.replace(/[^A-Za-z0-9_]/g,"9"); code is very cool. It uses an often overlooked regular expression operator: the ^. If it is outside a bracket-bounded character class, it means to match right after the start of the string (inputted URL). If it has \ before it, it is a literal, so it refers to the ^ character. But if it is at the very beginning inside a character class, right after the [, it means negation. So the regular expression will match anything but these characters. Since we put it in a replace function in which we are replacing with a 9, the replace function and regular expression together mean we wish to replace everyhing that is not one of these characters with a 9.

The check_number() function: First we create a z array with all the acceptable characters in it. Then we check the input number and if it's under 6 or not a number—isNaN()—then we change it to 6. If it's over 12, we change it to 12. Next we use n=Math.floor(Math.random()*63); to return a random number between 0 and 62. The Math.random function gets numbers between 0 and 1. The Math.floor function rounds off to the next lowest integer. The a=a+z[n] expression adds z[n] to the currect value of a. This means we are looping through the for loop the same number of times that the input number of username characters represents. Each loop we add another character, since z[n] gets us a random character from the z array each time. We stick the username into the form's input field with the name username, so that when return true allows form submission, a PHP script can pick up the POSTed username.



Try the Regular Expression username Validator.

Good info site for learning about Regular Expressions.



<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1252">
<TITLE>Regular Expression Username Validator</TITLE>
<meta name="description" content="Good, Tested, Regular Expression Username Validators and a Random Username Generator">
<meta name="keywords" content="Regular Expression Username Validator,Random Username Generator,javascript Random Username Generator,javascript Regular Expression Username Validator,javascript, dhtml, DHTML">

<script language=javascript>

function check(){

var ck_username = /^[A-Za-z0-9_]{6,12}$/;
d=document.form;
if (document.form.username.value.search(ck_username)==-1)
{alert("Please only enter 6 to 12 letters, numbers and underscore for username.");d.username.value='';d.username.focus();return false}else
{alert("username validated OK.");d.username.value='';d.username.focus();return false}}

function check_edit(){
z="123456";
d=document.form2;
p=d.username.value;
l=p.length;
if (l<6) {p=p+z.slice(0,6-l)}
if (l>12) {p=p.slice(0,12)}
p=p.replace(/[^A-Za-z0-9_]/g,"9");
d.username.value=p;
var r=confirm("Press OK to accept "+p+" as username or Cancel to reject it.");
if (r==true){alert("Accepted");d.username.value='';d.username.focus();}else
{alert("It's rejected—try again.");d.username.value='';d.username.focus();}
return false;}

function check_number(){
var z=new Array
('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',
'0','1','2','3','4','5','6','7','8','9','_',
'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z');
d=document.form3;
p=d.usernamesize.value;
if (p<6||isNaN(p)){p=6}
if (p>12){p=12}
var a="";var n=0;var i=0;
for (i=0;i<p;i++){
n=Math.floor(Math.random()*63);//return a random num between 0 and 62
a=a+z[n];}
d.username.value=a;
var r=confirm("Press OK to accept "+a+" as username or Cancel to reject it.");
if (r==true){alert("Accepted");
d.usernamesize.value='';d.username.value='';d.usernamesize.focus();}else {alert("It's rejected—try again.");
d.usernamesize.value='';d.username.value='';d.usernamesize.focus();} return false;}

</script>
</HEAD>
<body>
<BR><BR><BR><BR>
<form style='margin-left:340px' name='form' action=" " method="POST" onsubmit="return check()">
Uppercase letters are okay. Use letters, numbers,
and underscore in your username.<br>
<INPUT maxLength="12" type="text" name="username" size="12">
<INPUT TYPE="SUBMIT" value="Submit Username">
<INPUT TYPE="RESET" value="reset">
</form>

<BR><BR><BR><BR>
<form style='margin-left:340px' name='form2' action=" " method="POST" onsubmit="return check_edit()">
Uppercase letters are okay. Use letters, numbers,
and underscore in your username.<br>Your username will be edited is you goof.<br>
<INPUT maxLength="12" type="text" name="username" size="12">
<INPUT TYPE="SUBMIT" value="Submit Username">
<INPUT TYPE="RESET" value="reset">
</form>

<BR><BR><BR><BR>
<form style='margin-left:340px' name='form3' action=" " method="POST" onsubmit="return check_number()">
RANDOM USERNAME GENERATOR 6 TO 12 CHARACTERS LONG<BR>Your username will be generated now.<br>
<INPUT maxLength="2" type="text" name="usernamesize" size="2"> How many characters?<br>
<INPUT TYPE="SUBMIT" value="Submit Username Length"> <INPUT TYPE="RESET" value="reset"><br>
<INPUT type="text" name="username" size="30"> NEW USERNAME<BR>
</form>

</BODY>

</HTML>