Blame view

www-backend/js0/validate.js 4.58 KB
1ea3b987   Administrator   maby first commit
1
2
3
4
  $(document).ready(function()
  {
  
  
5ead64b0   Administrator   090316
5
  
1ea3b987   Administrator   maby first commit
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
      function checkStatus(data, form){
          var status = data.prop("checked");
  
          if( status )
          {
              $(form).validate({
                  rules: {
                      name: {
                          required: true,
                          maxlength: 255,
                          remote: {
                              url: "/check_ajax_data",
                              type: "get",
                              data: {
                                  name: function() {
                                      return $( "#name" ).val();
                                  },
                                  id: function() {
                                      var new_id = $( "#id" ).val();
                                      if(new_id){
                                          return new_id;
                                      } else {
                                          return 0;
                                      }
                                  }
                              }
                              }
                      },
                      page_meta_title_1:{
                          required: true
                      },
                      template_name: {
                          required: true,
                          maxlength: 255
                      },
                      template_title: {
                          required: true,
                          maxlength: 255
                      },
                      utm_source: {
                          required: true,
                          maxlength: 255
                      },
                      utm_medium: {
                          required: true,
                          maxlength: 255
                      },
                      utm_content: {
                          required: false,
                          maxlength: 255
                      },
                      utm_campaign: {
                          required: true,
                          maxlength: 255
                      }
                  },
                  messages: {
                      name: {
                          required: "Это обязательное поле.",
                          maxlength: "Поле содержит слишком много символов",
                          remote: "Это название уже занятно"
                      },
                      template_name: {
                          required: "Это обязательное поле.",
                          maxlength: "Поле содержит слишком много символов"
                      },
                      template_title: {
                          required: "Это обязательное поле.",
                          maxlength: "Поле содержит слишком много символов"
                      },
                      utm_source: {
                          required: "Это обязательное поле.",
                          maxlength: "Поле содержит слишком много символов"
                      },
                      utm_medium: {
                          required: "Это обязательное поле.",
                          maxlength: "Поле содержит слишком много символов"
                      },
                      utm_content: {
                          maxlength: "Поле содержит слишком много символов"
                      },
                      utm_campaign: {
                          required: "Это обязательное поле.",
                          maxlength: "Поле содержит слишком много символов"
                      }
                  }
              });
          } else {
1ea3b987   Administrator   maby first commit
94
  
5ead64b0   Administrator   090316
95
96
97
98
99
100
101
102
103
              var setting = $(form).validate().settings;
              delete setting.rules.utm_source;
              delete setting.messages.utm_source;
  
              delete setting.rules.utm_medium;
              delete setting.messages.utm_medium;
  
              delete setting.rules.utm_term;
              delete setting.messages.utm_term;
1ea3b987   Administrator   maby first commit
104
  
5ead64b0   Administrator   090316
105
106
              delete setting.rules.utm_content;
              delete setting.messages.utm_content;
1ea3b987   Administrator   maby first commit
107
  
5ead64b0   Administrator   090316
108
109
              delete setting.rules.utm_campaign;
              delete setting.messages.utm_campaign;
1ea3b987   Administrator   maby first commit
110
  
1ea3b987   Administrator   maby first commit
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
  
          }
      }
  
      var form = $('#email_event_add_edit');
      var data = $('#utm_status');
  
      checkStatus(data, form);
  
      data.change(function(){
          checkStatus(data, form);
      });
  
      form.submit(function(){
          return $(this).valid();
      });
  
  
  
      ///////////////////////////////////////////////////////////////////////
  
  });