1. #1
    Sencha User
    Join Date
    Jun 2011
    Posts
    12
    Vote Rating
    0
    mjfigur is on a distinguished road

      0  

    Question Ext.form.DateField and calling JQuery function if valid

    Ext.form.DateField and calling JQuery function if valid


    All, I have the following code to create a DateField and it works well but now I am in need to checking to see if the date inputted is valid then execute a JQuery functions called: refreshEmp.

    Here is the code:

    Code:
    new Ext.form.DateField({
                id: dt.id,
                applyTo: dt,
                "format": 'm/d/Y',
    			invalidClass : 'ux-status-error',
    			validateOnBlur : true,
    I read that there is the validate method but just new to ExtJs and cannot figure out how to put in an if statement that would then execute this JQuery function.

  2. #2
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,624
    Vote Rating
    331
    skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future

      0  

    Default


    By a jQuery function I assume you just mean a JavaScript function? If you take a look at this page of the docs:

    http://dev.sencha.com/deploy/ext-3.4...form.DateField

    and scroll down to the very bottom, you'll see the last event is valid. There are a few ways to register event listeners, one of which is:

    Code:
    new Ext.form.DateField({
        ...
        listeners: {
            valid: function(dateField) {
                refreshEmp(...);
            }
        }
    });
    Depending on what arguments refreshEmp() takes you may be able to reduce this down to just:

    Code:
    new Ext.form.DateField({
        ...
        listeners: {valid: refreshEmp}
    });
    Alternatively, if you are explicitly calling validate() you might want to do something like this:

    Code:
    if (dateField.validate()) {
        refreshEmp(...);
    }
    or even:

    Code:
    if (dateField.isValid()) {
        refreshEmp(...);
    }

  3. #3
    Sencha User
    Join Date
    Jun 2011
    Posts
    12
    Vote Rating
    0
    mjfigur is on a distinguished road

      0  

    Default Thank you

    Thank you


    Thank you so much you have been such a major help in understanding the official documentation.

Thread Participants: 1

Tags for this Thread