skip to Main Content

I have a modal that has textboxes in it, and if a user did not input any details in the textbox, I want it to not save the record. I have a notiflix confirmation popup that will ask the user before they will save the record. The problem is if one of the textboxes has no details and I press save, it will show an error $(...).valid() is not a function

Here is my code


    if ($('#insertmain').valid()){ //insertmain is the id of modal

References:

<script src="~/Scripts/jquery.validate.min.js"></script>
<script src="~/Scripts/jquery-3.6.3.min.js"></script>

2

Answers


  1. Chosen as BEST ANSWER

    I have found my mistake. It seems I have a different jquery reference in Layout.cshtml and I just need to remove that. It works now but validate is always returning true even if I leave empty spaces on a textarea.


  2. Try to add in this way as you are using valid function before jquery library

    <script src="~/Scripts/jquery-3.6.3.min.js"></script>
    <script src="~/Scripts/jquery.validate.min.js"></script>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search