Feb 20, 2015, 7:49 AM
Remote Validation: How to set default valid state
I want to set the valid state of datefield which is remote validated to some value. I have a working solution but I think it's not the right way.
Durign start up the field should always validate to true, only when the value of the field changes the remote validation should be triggered. Default is that the field valid state is false.
Durign start up the field should always validate to true, only when the value of the field changes the remote validation should be triggered. Default is that the field valid state is false.
protected void CheckValidFrom(object sender, RemoteValidationEventArgs e)
{
DateField validFromField = sender as DateField;
if (validFromField != null && validFromField.Value as DateTime? > LockDate)
{
e.Success = true;
}
else
{
e.Success = false;
e.ErrorMessage = "'Valid' is valid value only";
}
}
<x:DateField
ID="ValidFrom"
runat="server"
AllowBlank="False"
Width="250"
Vtype="daterange"
Enabled="false"
DataIndex="ValidFrom"
IsRemoteValidation="True">
<RemoteValidation OnValidation="CheckValidFrom" ValidationEvent="change" EventOwner="Field"></RemoteValidation>
<CustomConfig>
<x:ConfigItem Name="endDateField" Value="#{ValidTo}" Mode="Value" />
</CustomConfig>
</x:DateField>
// Bind Value to datefield JavaScript
window.Ext.getCmp('<%=ValidFrom.ClientID%>').rvConfig.remoteValid = true;
window.Ext.getCmp('<%=ValidFrom.ClientID%>').rvConfig.remoteValidated = true;
window.Ext.getCmp('<%=ValidFrom.ClientID%>').setValue(rec.get('ValidFrom'));
regards