PDA

View Full Version : [CLOSED] Remote Validation questions



bogc
Mar 05, 2013, 7:28 PM
Hello:

I am looking for some suggestions...

I have the following issue: I have a text field that has been configured with remote validation fired to the blur event. Now, the users sometimes enter the value in the text field, then they click the save button (without tabbing off the field) which triggers the remote validation as well. The save action calls the form submit function. From what I've seen, if the remote validation is fired, while it is executing, the field is marked as invalid, so the save server action won't be executed because the form isValid returns false. In Chrome, sometimes the sequence of events leads to a transaction aborted error.

So, here are some options:
- in the save button handler detect that a remote validation is being executed and display some message (I like this best). Is there a way to detect that a field is being remote validated without resorting to custom variables?

- Disable the save button while the validation runs.

- fire the remote validation on the change event instead of (or perhaps in addition to) blur.

Other ideas or suggestions?

Thanks!

bogc
Mar 06, 2013, 1:50 AM
I ended up implementing the function in this thread: http://forums.ext.net/showthread.php?23794-Turn-RemoteValidation-on-off&p=104041&viewfull=1#post104041

and I call it the first thing in the save button handler.

You can close this thread (I would appreciate any suggestions though).

Thanks

Baidaly
Mar 06, 2013, 1:50 AM
Hello!

My suggestion is to listen change event of every field with RemoteValidation and disable button to any change:



<%@ Page Language="C#" %>

<%@ Register assembly="Ext.Net" namespace="Ext.Net" tagprefix="ext" %>

<script runat="server">
protected void CheckField(object sender, RemoteValidationEventArgs e)
{
TextField field = (TextField)sender;

if (field.Text == "Valid")
{
e.Success = true;
}
else
{
e.Success = false;
e.ErrorMessage = "'Valid' is valid value only";
}

System.Threading.Thread.Sleep(500);
}
</script>

<!DOCTYPE html>

<html>
<head runat="server">
<title>Ext.NET Examples</title>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" />

<ext:FormPanel
runat="server"
Title="Remote Validation Form"
BodyPadding="5"
Frame="true"
MonitorValid="true"
Width="500"
DefaultAnchor="100%">
<FieldDefaults>
<CustomConfig>
<ext:ConfigItem Name="LabelWidth" Value="250" Mode="Raw" />
<ext:ConfigItem Name="PreserveIndicatorIcon" Value="true" Mode="Raw" />
</CustomConfig>
</FieldDefaults>
<Items>

<ext:TextField runat="server" FieldLabel="Server only validation" IsRemoteValidation="true">
<RemoteValidation OnValidation="CheckField" Delay="0" />
<Listeners>
<Change Handler="#{Button1}.disable();" Buffer="100"></Change>
</Listeners>
</ext:TextField>

</Items>
<Buttons>
<ext:Button ID="Button1" runat="server" Text="Submit" Disabled="true">
<Listeners>
<Click Handler="console.log(Ext.TaskManager.tasks);"></Click>
</Listeners>
</ext:Button>
</Buttons>
<Listeners>
<ValidityChange Handler="#{Button1}.setDisabled(!valid);" />
</Listeners>
</ext:FormPanel>
</form>
</body>
</html>

bogc
Mar 06, 2013, 2:19 AM
I like this approach. Thank you!

Baidaly
Mar 06, 2013, 5:52 AM
We've tested more and it's better to remove buffer due to user will not be able to press the button:


<Listeners>
<Change Handler="#{Button1}.disable();" Buffer="100"></Change>
</Listeners>

Can we close this thread?

bogc
Mar 06, 2013, 7:07 AM
Yes. Thank you!