|
-
Aug 26th, 2004, 07:56 PM
#1
Thread Starter
Fanatic Member
EZ one, validation
Well, I want my usernames to only consist of characters and numbers... no symbols such as $%^ etc
Right now, what is two variables...
strUsername
strAsciiCode = "ABCD...abcd...1234...._-"
strAsciiCode contains all the characters that are acceptible.
I do a for loop
The pcode looks like this:
Code:
for length of username
for length of asciicode
check if selected character in username cooresponds to strAscii
if it does, keep going, if not, return false
end loop 2
end loop 1
Is there a better way of doing this? Just seems processor costly to do this... or am i really worrying about nothing?
ok, so... windows takes 1 minute to search for a file on my PC yet google.com takes 1 second to search the entire internet? 
-
Aug 26th, 2004, 07:58 PM
#2
[VBF RSS Feed]
There is a great war coming. Are you sure you are on the right side? Atleast I have chosen a side.
If I have been helpful, Please Rate my Post. Thanks.
This post was powered by : 
-
Aug 26th, 2004, 08:17 PM
#3
Re: EZ one, validation
Is there a better way of doing this? Just seems processor costly to do this... or am i really worrying about nothing? [/B]
You could Use RegEx, i am not too good with RegEx, but a google search should be enough . Since you are looping through a small string it shouldnt be a problem to use 2 loops.
[VBF RSS Feed]
There is a great war coming. Are you sure you are on the right side? Atleast I have chosen a side.
If I have been helpful, Please Rate my Post. Thanks.
This post was powered by : 
-
Aug 26th, 2004, 08:18 PM
#4
Thread Starter
Fanatic Member
Javascript, sorry
heres the code i just wrote it
Code:
function sUser_validate(strString)
{
var i = 0;
var j = 0;
var fFlag = 0;
for(i=0; i <= strString.length;i++)
{
for(j = 0; j <= objSI.sCart.sAscii.length;j++)
{
if(strString.substr(i,1) == objSI.sCart.sAscii.substr(j,1))
fFlag++;
}
if(fFlag == 0)
return false;
else
fFlag = 0;
}
return true;
}
Bah i just found out its not working the way it should. UGH...
anyway
objSI.sCart.sAscii is the list of all valid chars "ABCD... etc"
strString is the parameter that will be checked.
What happens when i actually use this function as so
sUser_validate('myname')
it works great
when i get the same input from a form
var objMyName = Request.Form('txtMyName') + '';
sUser_validate(objMyName);
it always returns true even if objMyName is something liek 'blahblah1234!!@#!@#'
ok, so... windows takes 1 minute to search for a file on my PC yet google.com takes 1 second to search the entire internet? 
-
Aug 26th, 2004, 08:24 PM
#5
Thread Starter
Fanatic Member
Wait, it works... i umm, was getting the wrong variable from the form. Anyhow, thats the code... looks efficent enough to me, what do you think D?
ok, so... windows takes 1 minute to search for a file on my PC yet google.com takes 1 second to search the entire internet? 
-
Aug 26th, 2004, 08:27 PM
#6
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|