Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

String validation trouble 1

Status
Not open for further replies.

frozenpeas

Technical User
Sep 13, 2001
893
CA
Hello,

I am trying to limit a string to only alphanumeric characters. The trouble is that it will allow illegal characters as long as legal characters are also in the string.

"THIRTY" is allowed;
"30" is allowed;
"+" is not allowed;
"30+" is allowed but should not be allowed;

Here is the state of my function:

Code:
var checkChars:Function = function(input){
		var i:Number = 0;
		while(i<txtinput.length && (" abcdefghijklmnopqrstuvwxyz0123456789").indexOf(input.charAt(i)) != -1){
			goodString = true;
			i++;
		}
		if(goodString==true){
			return 1;
		}else{
			return -1;
			errFlag = true;
		}
	}

Thanks everyone.

frozenpeas
--
Micfo.com Affiliate Program
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top