1. #111
    Sencha User
    Join Date
    Feb 2010
    Location
    Brescia
    Posts
    60
    Vote Rating
    0
    ladro1987 is on a distinguished road

      0  

    Default


    Hi,
    I have uses this plugin for the remote validation

    Quote Originally Posted by jsakalos View Post
    I've looked in my files and I've found that I do not use this plugin anymore but I use "ServerValidator". I do not have time now to make proper entries, links and demo in forum, anyway, try the following code - I'll post it proper way in a week, or so.

    PHP Code:
    // vim: ts=4:sw=4:nu:fdc=4:nospell
    /*global Ext, console */
    /**
     * @class Ext.ux.form.ServerValidator
     * @extends Ext.util.Observable
     *
     * Server-validates field value
     *
     * @author    Ing. Jozef Sakáloš
     * @copyright (c) 2008, by Ing. Jozef Sakáloš
     * @date      8. February 2008
     * @version   1.0
     * @revision  $Id: Ext.ux.form.ServerValidator.js 645 2009-03-24 02:35:56Z jozo $
     * 
     * @license Ext.ux.form.ServerValidator is licensed under the terms of
     * the Open Source LGPL 3.0 license.  Commercial use is permitted to the extent
     * that the code/component(s) do NOT become part of another Open Source or Commercially
     * licensed development library or toolkit without explicit permission.
     * 
     * <p>License details: <a href="http://www.gnu.org/licenses/lgpl.html"
     * target="_blank">http://www.gnu.org/licenses/lgpl.html</a></p>
     *
     * @donate
     * <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank">
     * <input type="hidden" name="cmd" value="_s-xclick">
     * <input type="hidden" name="hosted_button_id" value="3430419">
     * <input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-butcc-donate.gif" 
     * border="0" name="submit" alt="PayPal - The safer, easier way to pay online.">
     * <img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
     * </form>
     */

    Ext.ns('Ext.ux.form');

    /**
     * Creates new ServerValidator
     * @constructor
     * @param {Object} config A config object
     */
    Ext.ux.form.ServerValidator = function(config) {
        
    Ext.apply(thisconfig, {
             
    url:'/request.php'
            
    ,method:'post'
            
    ,cmd:'validateField'
            
    ,paramNames:{
                 
    valid:'valid'
                
    ,reason:'reason'
            
    }
            ,
    validationDelay:500
            
    ,validationEvent:'keyup'
            
    ,logFailure:true
            
    ,logSuccess:true
        
    });
        
    Ext.ux.form.ServerValidator.superclass.constructor.apply(thisarguments);
    }; 
    // eo constructor

    // extend
    Ext.extend(Ext.ux.form.ServerValidatorExt.util.Observable, {

        
    // {{{
        
    init:function(field) {
            
    this.field field;
            
    // save original functions
            
    var isValid field.isValid;
            var 
    validate field.validate;

            
    Ext.apply(field, {
                
    // is field validated by server flag
                 
    serverValidundefined !== this.serverValid this.serverValid true
    //             serverValid: true

                 // private
                
    ,isValid:function(preventMark) {
                    if(
    this.disabled) {
                        return 
    true;
                    }
                    return 
    isValid.call(thispreventMark) && this.serverValid;
                }

                
    // private
                
    ,validate:function() {
                    var 
    clientValid validate.call(this);

                    
    // return false if client validation failed
                    
    if(!this.disabled && !clientValid) {
                        return 
    false;
                    }

                    
    // return true if both client valid and server valid
                    
    if(this.disabled || (clientValid && this.serverValid)) {
                        
    this.clearInvalid();
                        return 
    true;
                    }

                    
    // mark invalid and return false if server invalid
                    
    if(!this.serverValid) {
                        
    this.markInvalid(this.reason);
                        return 
    false;
                    }

                    return 
    false;
                } 
    // eo function validate

            
    }); // eo apply

            // install listeners
            
    this.field.on({
                 
    render:{single:truescope:thisfn:function() {
                    
    this.serverValidationTask = new Ext.util.DelayedTask(this.serverValidatethis);
                    
    this.field.el.on(this.validationEvent, function(e){
                        
    this.field.serverValid false;
                        
    this.filterServerValidation(e);
                    }, 
    this);
    //                this.field.el.on({
    //                    keyup:{scope:this, fn:function(e) {
    //                        this.field.serverValid = false;
    //                        this.filterServerValidation(e);
    //                    }}
    ////                    ,blur:{scope:this, fn:function(e) {
    ////                        this.field.serverValid = false;
    ////                        this.filterServerValidation(e);
    ////                    }}
    //                });
                
    }}
            });
        } 
    // eo function init
        // }}}
        
        
    ,serverValidate:function() {
            var 
    options = {
                 
    url:this.url '?#' + (this.name || this.field.name)
                ,
    method:this.method
                
    ,scope:this
                
    ,success:this.handleSuccess
                
    ,failure:this.handleFailure
                
    ,params:this.params || {}
            };
            
    Ext.applyIf(options.params, {
                 
    cmd:this.cmd
                
    ,field:this.name || this.field.name
                
    ,value:this.field.getValue()
                ,
    table:this.table
            
    });
            
    Ext.Ajax.request(options);
        } 
    // eo function serverValidate

        // {{{
        
    ,filterServerValidation:function(e) {
            if(
    this.field.value === this.field.getValue()) {
                
    this.serverValidationTask.cancel();
                
    this.field.serverValid true;
                return;
            }
            if(!
    e.isNavKeyPress()) {
                
    this.serverValidationTask.delay(this.validationDelay);
            }
        } 
    // eo function filterServerValidation
        // }}}
        // {{{
        
    ,handleSuccess:function(responseoptions) {
            var 
    o;
            try {
    Ext.decode(response.responseText);}
            catch(
    e) {
                if(
    this.logFailure) {
                    
    this.log(response.responseText);
                }
            }
            if(
    true !== o.success) {
                if(
    this.logFailure) {
                    
    this.log(response.responseText);
                }
            }
            
    this.field.serverValid true === o[this.paramNames.valid];
            
    this.field.reason o[this.paramNames.reason];
            
    this.field.validate();
        } 
    // eo function handleSuccess
        // }}}
        // {{{
        
    ,handleFailure:function(responseoptions) {
            if(
    this.logFailure) {
                
    this.log(response.responseText);
            }
        } 
    // eo function handleFailure
        // }}}
        // {{{
        
    ,log:function(msg) {
            if(
    console && console.log) {
                
    console.log(msg);
            }
        } 
    // eo function log
        // }}}

    }); 
    Take a look also at docs: http://extjs.eu/docs/?class=Ext.ux.form.ServerValidator

    This is my textfield:
    Code:
                    xtype:'textfield',
                    fieldLabel: 'E-mail',
                    name: 'email',
                    vtype:'email',
                    vtypeText: 'Inserisci un\'email valida',
                    anchor:'95%',
                    blankText:'Inserisci la tua <b>email</b>',
                    msgTarget: 'under',
                    allowBlank: false,
                    plugins:[new Ext.ux.form.ServerValidator({
                        url:'valid/ins_email_check.php'
                    } )]
                    /*plugins:[Ext.ux.plugins.foServerValidator],
                    rvOptions: {
                        url:'valid/ins_email_check.php'
                    }*/
    And this is some of my php code:

    PHP Code:
        $post $_POST;

        
    $field = @$post["field"];
        
    $value = @$post["value"];

        
    $o = new stdClass;
        
    $o->success true;
        
    $o->valid false;

            
    $sql="
                SELECT nome
                FROM utents
                WHERE username='"
    .$value."'
            "
    ;
            
    $query=mysql_query($sql) or die("Errore SQL: ".mysql_error()."<br />".dbg_box($sql));
            if (!
    mysql_num_rows($query)){
                
    $o->valid true;
                unset(
    $o->reason);
            }else
                
    $o->reason "Username Exist";

        
    header("Content-Type: application/json");
        echo 
    json_encode($o); 
    The problem is that if the username not exist into the table (condition without errors), it show the error's message "The value in this field is invalid".

    If show the error's message present into "reason" (Username Exist), it show this message also when the username not exist.
    Don't reset the reason?

    I have upgrade the plugin but not the PHP code.

    Into the PHP code change the sintax?

    Thanks

    Roberto.

  2. #112
    Sencha - Community Support Team jsakalos's Avatar
    Join Date
    Apr 2007
    Location
    Slovakia
    Posts
    27,167
    Vote Rating
    323
    jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future

      0  

    Default


    Javascript of the plugin reacts on the basis of response received from the server. Return responses that reflect your statuses and everything will be OK.
    Jozef Sakalos, aka Saki

    Education, extensions and services for developers at new http://extjs.eu
    News: Blessing and Curse of refs, Grid MultiSearch Plugin


  3. #113
    Sencha User
    Join Date
    Jun 2009
    Location
    Burlington, Ontario
    Posts
    174
    Vote Rating
    2
    Bleak is on a distinguished road

      0  

    Default


    I had an issue with the ServerValidator always sending the original value into the options.params.value. I believe it was related to this function

    PHP Code:
           Ext.applyIf(options.params, {
                
    cmd:this.cmd
                
    ,field:this.name || this.field.name
                
    ,value:this.field.getValue()
                ,
    table:this.table
            
    }); 
    As any subsequent calls would already have a value attribute in the params object. I changed it to use Ext.apply.. instead of Ext.applyIf.

    PHP Code:
           Ext.apply(options.params, {
                
    cmd:this.cmd
                
    ,field:this.name || this.field.name
                
    ,value:this.field.getValue()
                ,
    table:this.table
            
    }); 
    Unless I am missing something with how I call it, which is as follows;

    PHP Code:
    plugins     : [new Ext.ux.form.ServerValidator({
                       
    url       'pp.do',
                       
    params :  {ACTION'ValidateNewProjectName'xaction'read'entity'subscriber'}
                    })] 

  4. #114
    Sencha - Community Support Team jsakalos's Avatar
    Join Date
    Apr 2007
    Location
    Slovakia
    Posts
    27,167
    Vote Rating
    323
    jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future

      0  

    Default


    I've never run into that problem because I've never set this.params. Anyway, it is a bug that is fixed by your change. Thank you.
    Jozef Sakalos, aka Saki

    Education, extensions and services for developers at new http://extjs.eu
    News: Blessing and Curse of refs, Grid MultiSearch Plugin


  5. #115
    Sencha Premium Member
    Join Date
    Apr 2011
    Posts
    14
    Vote Rating
    1
    masood is on a distinguished road

      0  

    Default


    Hi
    Im a newbie to extjs. This plugin works great and thanx for creating it.
    One issue I seem to be having is with the remoteValid flag. It doesnt seem to change the behavior even if I set it to true or false. In order to get it to work I changed the the following in the plugin:
    PHP Code:
    Ext.apply(field, {
                
    remoteValidfield.remoteValid || false
    ... 
    Is this the correct way to do it? Or am i missing something?

  6. #116
    Sencha User
    Join Date
    Oct 2010
    Posts
    4
    Vote Rating
    0
    xplain is on a distinguished road

      0  

    Default campatibility extjs 4

    campatibility extjs 4


    Is the plugin compatible with extjs 4? If not can someone rewrite it for extjs 4

  7. #117
    Ext Premium Member yyogev's Avatar
    Join Date
    Jun 2009
    Location
    Shoham, Israel
    Posts
    196
    Vote Rating
    6
    yyogev is on a distinguished road

      0  

    Default Fix for ExtJS 4

    Fix for ExtJS 4


    to make the validation work in ExtJS 4, I replaced
    Code:
    var clientValid = validate.call(this);
    with
    Code:
    var clientValid = isValid.call(this);
    I am not very familiar with the inner workings of this class, so I'd be hapy to hear your comments on this change.
    Yaron Yogev

    IT Software Developer

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar