Validate a String

Filed in Computer Science by on May 10, 2015 0 Comments
// setup text field 
var enteredString:String = ''; 
 
// enter correct answer here 
var correctAnswer:String = 'correct answer'; 
correctAnswer = correctAnswer.split(' ').join('').toLowerCase();     

///////////////////////   GRADE    ///////////////////////////// 
 
function onGradeBtnPress(event:MouseEvent):void 
{             
    // set to lowercase, spaces removed, then compared      
    enteredString = textField.text;     
    enteredString = enteredString.split(' ').join('').toLowerCase();         
     
    if (enteredString == correctAnswer) 
    { 
        // Correct                 
    } 
    else  
    { 
        // Incorrect                       
    }             
     
}

Tags: ,

About the Author ()

Whether it's programming, designing a user interface, planning a network, or playing jazz, Marshall enjoys learning about new technology, and being creative.

Leave a Reply

Your email address will not be published. Required fields are marked *