Search code examples
asp.netjquerycustomvalidator

How to validate if a record exists in Sql with JQuery?


i have an app and when i write a number in a textbox,i have to check if this number exists in database or not.How can i do that with Custom Validator and JQuery Ajax functions ? Thank you so much in advance


Solution

  • You can not write a JavaScript to connect to SQL.

    1. write a function in your js to ajax post your textbox value to a server side validation method.
    2. Serverside validation method check given value with your database and return true or false.
    3. validation function in your js reflect properly with your ajax post results on success.

    References to study: 1. api.jquery.com: look for $.post