int _Dosagelimit = 3;
etDosage.TextChanged += (sender, args) =>
{
int n;
var isNumeric = int.TryParse(etDosage.Text, out n);
if (isNumeric)
{
string _text = etDosage.Text; //Get Current Text
if (_text.Length > _Dosagelimit) //If it is more than your character restriction
{
_text = _text.Remove(_text.Length - 1); // Remove Last character
etDosage.Text = _text; //Set the Old value
}
}
else
{
string _text = etDosage.Text;
if (_text.Length > 0)
{
_text = _text.Remove(_text.Length - 1);
etDosage.Text = _text;
}
}
};
etDosage.TextChanged += (sender, args) =>
{
int n;
var isNumeric = int.TryParse(etDosage.Text, out n);
if (isNumeric)
{
string _text = etDosage.Text; //Get Current Text
if (_text.Length > _Dosagelimit) //If it is more than your character restriction
{
_text = _text.Remove(_text.Length - 1); // Remove Last character
etDosage.Text = _text; //Set the Old value
}
}
else
{
string _text = etDosage.Text;
if (_text.Length > 0)
{
_text = _text.Remove(_text.Length - 1);
etDosage.Text = _text;
}
}
};
No comments:
Post a Comment