Validation Studying

2 posts, 0 answers
  1. Chenkai
    Chenkai avatar
    5 posts
    Member since:
    May 2014

    Posted 19 May 2014 Link to this post

    At first, Thanks for kendo. it is used conveniently. but there are some ways I can't understand or I think it's not elegant.

    1. $("#temp").kendoValidator().data("kendoValidator").validate() doesn't validate rules which I specify.
    I add my rules in Validation to validate password and confirm password. when element loses focus, fantastic!!!! It does work. I really happily continue coding.

    if( !$("#temp").kendoValidator().data("kendoValidator").validate() ){
         return false;
    }
    when I submit data with AJAX. Oh no.. break down because I write different password in password input and confirm Password input. I realize that validate() don't use rules. I don't know why?  The only reason I can find is rules need know the real <input> widget.

    2. form submit.
    I don't find some solutions. So I return to use form submit which likes:
    <form>
        <input name="username" required /> <br />
        <button id="save">Save</button>
      </form>
     
      <script>
        // attach a validator to the container
        $("form").kendoValidator({
            validate: function(e) {
                console.log("valid" + e.valid);
            }
        });
      </script>
    it works. when I submit, e.valid validates rules. but it refresh web. Oh no, I don't want the way refreshes my web because I want to make SPA with AJAX. So I add onsubmit="return false" in <form>. but I think it is not elegant. I don't like it. If kendo can integrate these. it will be brilliant and elegant.


    Best regards. 


  2. Alexander Valchev
    Admin
    Alexander Valchev avatar
    2875 posts

    Posted 20 May 2014 Link to this post

    Hi Chenkai,

    Regarding your issues:

    1. The issue occurs because you are re-initializing the validator with empty settings.
    $("#temp") //select element
      //.kendoValidator() //initialize validator
      .data("kendoValidator") //get validator client side object
      .validate() //call the method

    Removing the code marked in red should resolve the problem.

    2. Your question is not directly related to Kendo UI but to general programming knowledge about "how to submit forms with jQuery.ajax". There are a lot of tutorial on the internet which explain in steps how this can be done (here is one example). Please search the web for a tutorial related to the server side platform you are using.

    Regards,
    Alexander Valchev
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  3. Kendo UI is VS 2017 Ready
Back to Top