0

when i submit form, adno field (number) not validate excluding empty

my template.html

<input name="adno" id="id_adno" type="number" class="form-control" placeholder="" required>

jquery validate remote

        adno: {
          remote: {
            url: "{% url 'is_adno_valid' %}",
            type: "post",
            data: {
              field_value: function () {
                return $("#id_adno").val();
              },
              csrfmiddlewaretoken: "{{ csrf_token }}"
            }
          }
        },

views.py and urls.py

def is_adno_valid(request):
    adno = int(request.POST.get('adno'))
    return JsonResponse({'status':adno==1111})

urls.py

path('is_adno_valid',views.is_adno_valid, name='is_adno_valid'),


when i try to submit form with adno field as empty, red border of error showing. but whe enter any number it not showing error. ie, remote not working

Ali
  • 3
  • 1
  • 2
  • Review the documentation for the `remote` method. You are supposed to return a *"JSON string that must be "true" for valid elements"*. Instead, you are returning a boolean `true`. I am also not sure about the use of `return`. What is the Python equivalent of `echo`? See: https://jqueryvalidation.org/remote-method/ – Sparky Mar 27 '23 at 17:41
  • Also, you're expected to post some troubleshooting results here. Like inspecting your console for server responses, errors, etc. – Sparky Mar 27 '23 at 19:29

0 Answers0