Hello
I have tried to make validation code for an input box (flash 8) however I cant seem to get it to work, heres the code i have
allow = 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”,” ",“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”);
function validate(user_name){
for(i=0;i<allow.length;i++){
if(user_name.indexOf(allow*) != -1){
temp2++
}
}
}
// when the user presses the button it runs teh following code
btn_continueS3.onPress = function(){
//runs the validation
validate(user_name)
if(user_name.length==temp2){
temp1=0}else{temp2=0
error_messege=" Please ONLY use letters of the english Alphabet";
}
if(temp1==0){
gotoAndPlay("Scene 2", 1)
}
}
The basic gist is that it runs throught the input box and checks if the letters are in the array, and if they are it adds 1 to temp2
then at the end it checks how many characters are in the input box, and if they equal == temp2 then it goes to the next scene, else it says “Please…etc”
The PROBLEM is that if the user types in a letter twice, such as " HELLO" then the code only counts 1 L instead of 2 L’s. so then it throws out the sum because it wont be correct.
Any ideas?
Thanks
-ghozt123