Requirement: I want it to do dynamically. I do not want the user to see a special character entered into the textBox. Instead of the special character the user should see only a blank space entered in the place of the special character. Is it possible to do such event. I tried many ways but could not achieve it. Its is very challenging , someone please help me
MXML Code:
<mx:TextInput x="10" y="25" id="txtSearch" width="200" enter="btnSearch_Click();" keyDown="txtSearch_KeyUpHandler(event);"/>
AS Code:
private function txtSearch_KeyUpHandler(event:KeyboardEvent):void {
if(!((event.charCode >= 48 && event.charCode <= 57)||(event.charCode >= 65 && event.charCode <= 90)||(event.charCode >= 97 && event.charCode <= 112)))
{
//event.preventDefault();
event.charCode = 32;
}
}
When I execute the above code, it did not execute as expected. The special characters are being entered in the txtSearch text box. I am not sure about what has went wrong here. Can you please help me. Thanks in Advance
The solution of the above is
at the enter function loop the text entered, and
search for special character and replace with by space.
Its better to use the regular expression on the enter click.