Gossamer Forum
Home : Products : DBMan : Customization :

user ID name requirement?

Quote Reply
user ID name requirement?
I need to make sure that a person logging in uses a valid ham radio callsign (1 or 2 letters, a number, 1 to 3 letters). How can I check this requirement? I have a database in which I allow anyone to sign up, but I have gotten a few stragglers who are not hams signing in with creative names and posting.

Here are a few valid callsigns:

dl1gfr

kd4rdb

aa4ix

w1aw

Thanks!!

Wes
Quote Reply
Re: [kd4rdb] user ID name requirement? In reply to
Yep there is a way to run it through a "test" to validate the username... I'd recommend using Javascript so it would check for proper format before the user even clicks the submit button, otherwise you can do it in Perl and it will run the test then. I don't have a working example in front of me so maybe someone else can "bust one out" for you. If not, I'll see what I can find.
Quote Reply
Re: [kd4rdb] user ID name requirement? In reply to
just out of curiosity, how can you tell if any combination of letters, numbers & letters are valid.

would aa123aaa be valid? It meets your stated requirements.


Gene
"The older I get, the more I admire competence, just simple competence in any field from adultery to zoology."
Quote Reply
Re: [kd4rdb] user ID name requirement? In reply to
Here's a "quick and dirty" JavaScript solution... it's not fool-proof but it at least gives people the idea of what they are supposed to be typing in. You'll have to make two simple modifications to the html.pl file.

The modifications are below. It can be made a little more secure but that will involve a little more hacking.

I left in the "credits" (where I stole the base code from) so that you can see where to get some more ideas from.


##################### Step 1 add this to the <head></head> tags under html.pl in the subroutine html_signup_form


<SCRIPT LANGUAGE="JavaScript">

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Original code by Peter Haydon -->
<!-- peter_haydon@lineone.net -->

<!-- Begin
function postit(){ //check call sign format is valid
test = document.form1.userid.value; size = test.length
while (test.slice(0,1) == " ") //Strip leading spaces
{test = test.substr(1,size-1);size = test.length
}
while(test.slice(size-1,size)== " ") //Strip trailing spaces
{test = test.substr(0,size-1);size = test.length
}

document.form1.userid.value = test; //write back to form field
if (size < 4 || size > 8){ //Code length rule
alert(test + " is not a valid call sign - wrong length");
form1.userid.select();
}
if (!(isNaN(test.charAt(0)))) { //leftmost character must be alpha rule
alert(test + " is not a valid call sign - must start with a letter");
form1.userid.select();
}
if ((!(isNaN(test.charAt(1)))) && (!(isNaN(test.charAt(2))))) { //leftmost character must be alpha rule
alert(test + " is not a valid call sign - positions 2 and 3 cannot both be numbers");
form1.userid.select();
}
if ((isNaN(test.charAt(1))) && (isNaN(test.charAt(2)))) { //leftmost character must be alpha rule
alert(test + " is not a valid call sign - positions 2 and 3 cannot both be alpha");
form1.userid.select();
}
if (!(isNaN(test.charAt(3)))){ //character in position 4 must be alpha rule
alert(test + " is not a valid call sign - position 4 cannot be a number");
form1.userid.select();
}

count1 = test.indexOf(" ");count2 = test.lastIndexOf(" ");
return true;
}
// End -->
</script>


######################### Step 2 replace this

<input type="TEXT" name="userid" value="$in{'userid'}">


######## with this
<input type="TEXT" name="userid" value="$in{'userid'}" onChange="postit()">

Last edited by:

Watts: Apr 14, 2003, 2:42 PM
Quote Reply
Re: [esm] user ID name requirement? In reply to
Nope, only one number in the middle. I know this is a simple test with the matching in perl... problem is , i'm not good with s/ or m/ ....

something like m/[^A-Za-z]#[^A-Za-z] ... i dunno... I'm sunk.... but if I can get this matching done, I can make the DB.cgi flunk the username and bail out.

Wes