Hello @sveins12!
Fact is that no, there is no validation like we have with Ext.NET. At least for now, it has to be handled by the developer, with change events client or server-side, and applying CSS for visual feedback.
Here's a suggestion or starting point you could use for the validation part's visual feedback. As for functional feedback, you can just bind an
valid=true field to the
item object during the event (that will go straight to the App.DateField1.valid) that you could check before submitting, for example. Or just disable the submit/save button when any field is set to invalid.
@using Ext.Net.Mobile;
@using Ext.Net.Mobile.MVC;
@{
Layout = null;
var x = Html.X();
}
<!DOCTYPE html>
<html>
<head>
<title>Test DatePickerField</title>
<style type="text/css">
.invalid {
color: #ffaaaa;
font-weight: bold
}
</style>
</head>
<body>
@Html.X().ResourceManager()
@(x.FieldSet()
.ID("FieldSet1")
.FullScreen(true)
.Items(
x.DatePickerField()
.ID("DateField1")
.Label("Date")
.DestroyPickerOnHide(true)
.DateFormat("d.m.Y")
.Name("date")
.Picker(
x.DatePicker()
.YearFrom(1990)
.DateValue(new DateTime(2016, 6, 24))
)
.Listeners(l => l.Change.Handler = MvcUtils.StringifyScriptBlock(@<text>
<script type="text/javascript">
var fullYear = newDate.getFullYear(),
fieldSet = item.up('fieldset');
if (fullYear <= 2016) {
var message = "Year must be greater than 2016!";
if (fieldSet) {
fieldSet.setInstructions({
title: message,
baseCls: "x-form-fieldset-instructions invalid"
});
} else {
X.Msg.alert('Field validation error', message);
}
item.setLabelCls('invalid')
} else {
item.setLabelCls()
if (fieldSet) {
fieldSet.setInstructions();
}
}
</script>
</text>))
)
)
</body>
</html>
Hope this helps!