[CLOSED] FormPanel textfield w/remote validation reset issue

  1. #1

    [CLOSED] FormPanel textfield w/remote validation reset issue

    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
    Last edited by Daniil; Mar 04, 2013 at 6:03 PM. Reason: [CLOSED]
  2. #2
    You can set IgnoreLastValue="true" to prevent value checking with previous value
  3. #3
    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

Similar Threads

  1. [CLOSED] Issue with FormPanel reset
    By Daly_AF in forum 1.x Legacy Premium Help
    Replies: 6
    Last Post: Apr 26, 2012, 2:53 PM
  2. Replies: 3
    Last Post: Jul 11, 2011, 9:43 AM
  3. [CLOSED] Remote validation for textfield in MVC project
    By leon_tang in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Jul 08, 2011, 12:04 PM
  4. Replies: 0
    Last Post: Jun 30, 2011, 5:07 PM
  5. FormPanel Validation Issue (el is not defined)
    By inorder in forum 1.x Help
    Replies: 0
    Last Post: Mar 09, 2011, 11:03 AM

Posting Permissions