I'm using MonoTouch.Dialog for some forms. In the docs here:
https://github.com/migueldeicaza/MonoTouch.Dialog
it states that
"If you want to do data validation, you should do this when the user
triggers an action with the data entered. For example<snip> some
StringElement used as a button to go to the next stage.
This is where you would perform basic input validation, and perhaps more
complicated validation like checking for the validity of a user/password
combination with a server."
I'm trying to do some validation on EntryElement fields (I made them custom
MoneyElement fields) with code similar to this:
protected override MonoTouch.UIKit.UITextField CreateTextField
(System.Drawing.RectangleF frame)
{
textField = base.CreateTextField (frame);
textField.ShouldEndEditing += ShouldEndEditing;
return textField;
}
public bool ShouldEndEditing(UITextField textField)
{
decimal d;
if (!decimal.TryParse(textField.Text, out d))
{
//textField.ResignFirstResponder();
GuiUtils.ShowAlert("Invalid number entered");
return false;
}
return true;
}
The problem that I'm having is that if I press the Back button on the form
in the top left, the validation still triggers and also allows the back
navigation to occur. I'd like to prevent the navigation from happening,
which I assume will also fix the other error I'm having where the message
gets displayed 3-4 times after the back navigation has happened.
Any ideas?
--
View this message in context:
http://monotouch.2284126.n4.nabble.com/Prevent-DialogViewController-from-going-back-tp4657597.html
Sent from the MonoTouch mailing list archive at Nabble.com.
_______________________________________________
MonoTouch mailing list
[email protected]
http://lists.ximian.com/mailman/listinfo/monotouch