PDA

View Full Version : [CLOSED] FormPanel textfield w/remote validation reset issue



jwhitmire36
Mar 01, 2013, 7:53 PM
Hello,
I'm having an issue with a data entry form that uses remote validation, after the form fields are entered a button is clicked to save the data and 'reset' the form to enter another record. On a field with remote validation, the reset or clear doesn't truly clear the field, because if the same value is entered in a field the remote validation is not fired, it appears it thinks the value has not changed. In the below example it has 2 text fields, Text 1 has remote validation, upon initial load enter '1234' into Text 1 and and 'Tab' to next field, if debug and set breakpoint inside 'ValidateFields' routine you see the validation event fires. Enter anything in Text 2 and hit 'Save' button and the form is 'reset'. Now type '1234' into Text 1 again and 'Tab' and you will see the validation event is NOT fired, but if you go back and type 4567 the validation fires. How can I get the form field to truly clear so the validation event will fire again even though the same value is entered again?



<%@ Page Language="C#" %>
<%@ Register assembly="Ext.Net" namespace="Ext.Net" tagprefix="ext" %>

<script runat="server">
protected void btn1_Click(object sender, DirectEventArgs e)
{
// Save Data


// Reset Form to New Entry
txt1.Clear();
txt2.Clear();
FormPanel1.ClearInvalid();
}
protected void ValidateFields(object sender, RemoteValidationEventArgs e)
{
// Validation
TextField text1 = (TextField)sender;
if (text1.Text.Length > 0)
e.Success = true;
else
{
e.Success = false;
e.ErrorMessage = "Text1 is required.";
}
}
</script>

<!DOCTYPE html>
<html>
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<ext:ResourceManager runat="server"></ext:ResourceManager>
<ext:FormPanel ID="FormPanel1" runat="server" Layout="TableLayout" Title="Test Panel" BodyPadding="10" Width="500">
<LayoutConfig>
<ext:TableLayoutConfig Columns="2"></ext:TableLayoutConfig>
</LayoutConfig>
<Items>
<ext:TextField ID="txt1" runat="server" FieldLabel="Text 1" AllowBlank="false" IsRemoteValidation="true">
<RemoteValidation OnValidation="ValidateFields" ValidationEvent="blur" ShowBusy="false"></RemoteValidation>
</ext:TextField>
<ext:TextField ID="txt2" runat="server" FieldLabel="Text 2" AllowBlank="false"></ext:TextField>
<ext:Button ID="btn1" runat="server" Text="Save">
<DirectEvents>
<Click OnEvent="btn1_Click"></Click>
</DirectEvents>
</ext:Button>
</Items>
</ext:FormPanel>
</form>
</body>
</html>


If you're wondering why I need to re-validate the field, I have a Prime Key field that is entered by user and I want to make sure it is unique.
Thanks,
JW

Vladimir
Mar 01, 2013, 9:38 PM
You can set IgnoreLastValue="true" to prevent value checking with previous value

jwhitmire36
Mar 04, 2013, 4:21 PM
Thanks Vladimir, works good! I got focused on clearing the text field and didn't look closely enough at the validator, this can be closed.

JW