How to do validation of edittext programatically?

ranirani INMember

I am beginner to xamarin studio.i have one edittext. I have added that edittext dynamically.i want to that edittext allows only number and decimal point.How to do validation??


  • CortezCortez USMember ✭✭✭

    Hey @rani!

    I need this kind of validation by IP addresses. It allows only decimal numbers and point. I validated it with contrains the keyboard. In the XML i setted two parameter:

    <item name="android:inputType">numberDecimal</item> <item name="android:digits">.0123456789</item>

    It is from style but i think you understand this. In code i found the following possibility:

    EditText et = new EditText (); et.InputType = Android.Text.InputTypes.NumberFlagDecimal; et.SetOnKeyListener(DigitsKeyListener.GetInstance(".0123456789"));

Sign In or Register to comment.