RemoteValidation help (not firing on second blur)

  1. #1

    RemoteValidation help (not firing on second blur)

    Hello,

    I have a slight problem with a form here where I tried to activate RemoteValidation on one field. This is the simple textfield:

    <ext:TextField ID="ComputerName" IsRemoteValidation="true" runat="server" FieldLabel="Server" Value="<%# Model.ComputerName %>" AutoDataBind="true">
        <RemoteValidation Url="/DbSettings/Verify" Method="POST" ValidationEvent="blur" CleanRequest="true">
        </RemoteValidation>
    </ext:TextField>
    As expected the validation fires when the field lose focus (through click outside or tabbing out). But if I click in the field again and then click out again without changing it, the validation will not re-fire and the field will be marked as valid (even if it was not).

    Just for the sake of completeness this is the mock method (it will always fail):
    public ActionResult Verify(string id, string value)
            {
                var res = new JsonResult();
    
                res.Data = new { valid = false, message = "Error!" };
                
                return res;
            }
    (Also note that the returning message must have a "valid" and an optional "message" fields only and nothing else, nothing different or it will not be interpreted as a validation message, is that correct?).

    Regards.
  2. #2
    Hi,

    RemoteValidation is not fired if value is not changed since last validation
    Try to add the following listener to the field
    <Blur Handler="delete this.rvConfig.lastValue;" />
    Vladimir Shcheglov
    Sr. Developer
  3. #3
    HI Vladimir,

    That only works half of the time... meaning that the first "blur" will fire the validation while the second will not... the third will re-fire and so on.

    What type is rvConfig and where can I find some reference for it?

    Regards.
  4. #4
    Hi,We fixed few problems with remote validationThe fix will be available in next releaseHere is the fix (diff)You can apply this changes manually, rebuild scripts (build.bat) and rebuild Ext.Net assembly
    Index: D:/Projects/Coolite/svn.ext.net/trunk/Ext.Net/Build/Ext.Net/extnet/core/form/Field.js===================================================================--- D:/Projects/Coolite/svn.ext.net/trunk/Ext.Net/Build/Ext.Net/extnet/core/form/Field.js	(revision 3639)+++ D:/Projects/Coolite/svn.ext.net/trunk/Ext.Net/Build/Ext.Net/extnet/core/form/Field.js	(working copy)@@ -119,7 +119,12 @@         }          if (this.disabled || (clientValid && (!this.rvConfig.remoteValidated || this.rvConfig.remoteValid))) {-            this.clearInvalid();+            if (this.rvConfig.lastValue === this.getValue() && this.rvConfig.remoteValid === false) {+                this.markInvalid(this.rv_response.message || "Invalid");+            }+            else{+                this.clearInvalid();+            }             return this.rvConfig.remoteValid;         } @@ -137,7 +142,6 @@     performRemoteValidation : function (e) {                 if (this.rvConfig.lastValue === this.getValue()) {             this.rvTask.cancel();-            this.rvConfig.remoteValid = true;             return;         }                 @@ -149,14 +153,15 @@                     return;                 }             }--			this.rvConfig.remoteValid = false;-			this.rvConfig.remoteValidated = false;+			             this.rvTask.delay(this.rvConfig.validationBuffer);         }     },          remoteValidate : function () {+        this.rvConfig.remoteValid = false;+	    this.rvConfig.remoteValidated = false;+			         var dc = Ext.apply({}, this.remoteValidationOptions), 		    options = {params : {}};
    Vladimir Shcheglov
    Sr. Developer
  5. #5
    Index: D:/Projects/Coolite/svn.ext.net/trunk/Ext.Net/Build/Ext.Net/extnet/core/form/Field.js
    ===================================================================
    --- D:/Projects/Coolite/svn.ext.net/trunk/Ext.Net/Build/Ext.Net/extnet/core/form/Field.js	(revision 3639)
    +++ D:/Projects/Coolite/svn.ext.net/trunk/Ext.Net/Build/Ext.Net/extnet/core/form/Field.js	(working copy)
    @@ -119,7 +119,12 @@
             }
     
             if (this.disabled || (clientValid && (!this.rvConfig.remoteValidated || this.rvConfig.remoteValid))) {
    -            this.clearInvalid();
    +            if (this.rvConfig.lastValue === this.getValue() && this.rvConfig.remoteValid === false) {
    +                this.markInvalid(this.rv_response.message || "Invalid");
    +            }
    +            else{
    +                this.clearInvalid();
    +            }
                 return this.rvConfig.remoteValid;
             }
     
    @@ -137,7 +142,6 @@
         performRemoteValidation : function (e) {        
             if (this.rvConfig.lastValue === this.getValue()) {
                 this.rvTask.cancel();
    -            this.rvConfig.remoteValid = true;
                 return;
             }        
             
    @@ -149,14 +153,15 @@
                         return;
                     }
                 }
    -
    -			this.rvConfig.remoteValid = false;
    -			this.rvConfig.remoteValidated = false;
    +			
                 this.rvTask.delay(this.rvConfig.validationBuffer);
             }
         },
         
         remoteValidate : function () {
    +        this.rvConfig.remoteValid = false;
    +	    this.rvConfig.remoteValidated = false;
    +			
             var dc = Ext.apply({}, this.remoteValidationOptions),
     		    options = {params : {}};
    Vladimir Shcheglov
    Sr. Developer
  6. #6
    Hi Vladimir

    Thanks very much. For the time being I have also found another workaround as well:

    <Listeners>
        <Blur Handler="this.remoteValidate();" />
    </Listeners>
    And of course set ValidationEvent="false" in the RemoteValidation so it does not fire twice :)

    Regards.

Similar Threads

  1. [CLOSED] RemoteValidation not firing when text is not changed
    By FAS in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: May 09, 2012, 4:42 PM
  2. Replies: 6
    Last Post: Aug 01, 2011, 5:53 PM
  3. [1.1] RemoteValidation
    By Timothy in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Jul 12, 2011, 8:44 AM
  4. RemoteValidation ?
    By nanlinfeixue in forum 1.x Help
    Replies: 0
    Last Post: Jun 20, 2011, 11:49 AM
  5. Replies: 4
    Last Post: Aug 16, 2010, 9:39 AM

Tags for this Thread

Posting Permissions