PDA

View Full Version : can we write in UPPERCASE while caps Lock is off??



Gyan Singh
June 19th, 2009, 07:35 AM
HI friends,
I am making a quiz.
user will give answer in input text field, so i wrote like this,


submitBtn.addEventListener (MouseEvent.CLICK, q3);

function q3 (evt:MouseEvent):void {
var ans3T:String;
ans3T = inputTxt.text;

if (ans3T == "gyan")
{
trace ("correct answer");
} else
{
trace ("wrong answer");
}
}but problem is if user type Gyan or GYAN, it will say wrong so
how can i fix this problem,
can we write in UPPERCASE while caps Lock is off,
or
can we restrict UPPERCASE in input text Field ??

BoppreH
June 19th, 2009, 07:42 AM
Register the answers all in lower case and then check for

if (ans3T.toLowerCase() == "gyan")

It'll convert the text to lower case without the user even knowing it.

Gyan Singh
June 19th, 2009, 08:03 AM
Thanks, It'll work.

if I don't want receive input in number(1 2 3...) so how can i restrict..

inputTxt.restrict = "a-z"
inputTxt.restrict = "A-Z"

only one case (UPPER / lower) is working..

BoppreH
June 19th, 2009, 08:05 AM
I don't know of any built-in methods for this because I don't use text fields much, but you could do it yourself. Add a TEXT listener to the text field and remove any number that appears.

marc_
June 19th, 2009, 09:23 AM
my_txt.restrict = "A-Z a-z";