Hello, 1) I am looking for a method to check if a number (float) is written with "," or ".". Like "21,00" or "17.01". And correct the input.. 2) And I am searching a method to e.g. check if the user filled only numbers into a textfield.. Like "20" (correct) and "20ABC" (not correct) Does mono offer something like that for the Unity webplayer ? Greetings DH
Hi DynamicHead, 1. the easiest thing to do that is to convert the "," to "." and check the ammount of "." in your Textbox or you use Regular Expressions. 2. you can use TryParse to check the user input. Its a c# sample it would be run on Mono too. But you must change it with Input.GetAnyKey or something like that to catch the Event. Code (csharp): private void TextBox_KeyPress(object sender, KeyPressEventArgs e) { int isNumber = 0; e.Handled = !int.TryParse(e.KeyChar.ToString(), out isNumber); } I'm at the office atm, no Mac or Unity here [/quote]
Thank you. 1) Sounds good. Any idea how I can find out if the used computer uses the number format "," or "." ? Because this varies from language to language..
Hi, i dont know if it work with unity but you can use System.Globalisation in .net and mono. Link If you replace always the "," with "." you doesn't need the culture informations. Lars