1

I started with Jquery.validate to work. I try some tutorials but now I have come to a blocked state.

One this way I bind the rules and the messages to my form. Otherwise I do nothing with jquery on my form

$("#myform").validate({...})

Custom Code what I want to run.

$("#myform").find("#id_select_to").find("option").prop("selected", true);

How I can run custom code before the validation starts.

"#id_select_to" is the second pane what should get selected before validate. Widget is from the Django Admin.

Widget from Django

Azd325
  • 5,752
  • 5
  • 34
  • 57

1 Answers1

2

I found my answer on this answer https://stackoverflow.com/a/6472021/548558

How I can run custom code.

$("#myform").validate({
    select: {
      required: {
        depends:function(){
           $("#myform").find("#id_select_to").find("option").prop("selected", true);
           return true;
        }
     },
   },
})

Works very well.

Community
  • 1
  • 1
Azd325
  • 5,752
  • 5
  • 34
  • 57