Remote validation Not working as excepted

2 posts, 0 answers
  1. Shahram
    Shahram avatar
    6 posts
    Member since:
    Apr 2020

    Posted 15 Apr 2020 Link to this post

    I was searching for Grid remote validation and I reached your demo demo.
    I Have two questions .

    1-In this demo validator shows the error message but accepts the input.is there any way that we prevent adding record to data base when remote validation result is false?
    in your demo I have added many of the same name product and validation does not prevent me doing this.

    2-this message is not shown for editing. but I could not find how you handled this is source.

  2. Veselin Tsvetanov
    Admin
    Veselin Tsvetanov avatar
    1230 posts

    Posted 17 Apr 2020 Link to this post

    Hi Shahram,

    Here are the answers to your questions:

    1. What I would suggest you is to extend the remote validation rule, so that when false is returned, you could disable or hide the update button:

    success: function (data) {
      if (data == true) {
        input.attr("data-val-remote", "");
         input.closest('tr').find('.k-grid-update').show();
      } else {
        input.attr("data-val-remote", data);
        input.closest('tr').find('.k-grid-update').hide();
      }
    ...

    2. I am not quite sure about your second question. While editing an existing record in the Grid, in case an already existing name has been typed, the validation is still preset. You could see the image attached, demonstrating such a scenario.

    Regards,
    Veselin Tsvetanov
    Progress Telerik

    Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
    Our thoughts here at Progress are with those affected by the outbreak.
Back to Top