Results 1 to 6 of 6

Thread: EZ one, validation

  1. #1

    Thread Starter
    Fanatic Member invitro's Avatar
    Join Date
    Jan 2000
    Location
    Outside your window
    Posts
    547

    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?

  2. #2
    Big D Danial's Avatar
    Join Date
    Jul 2000
    Location
    ASP.Net Forum
    Posts
    2,877
    Javascript or VBScript?
    [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 :

  3. #3
    Big D Danial's Avatar
    Join Date
    Jul 2000
    Location
    ASP.Net Forum
    Posts
    2,877

    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 :

  4. #4

    Thread Starter
    Fanatic Member invitro's Avatar
    Join Date
    Jan 2000
    Location
    Outside your window
    Posts
    547
    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?

  5. #5

    Thread Starter
    Fanatic Member invitro's Avatar
    Join Date
    Jan 2000
    Location
    Outside your window
    Posts
    547
    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?

  6. #6
    Big D Danial's Avatar
    Join Date
    Jul 2000
    Location
    ASP.Net Forum
    Posts
    2,877
    Originally posted by invitro
    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?
    I just about started debugging it , glad you found the problem.

    Yes it looks good enough to me ...

    Good luck. Happy programming
    [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 :

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width