Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var callback_form = {
  2.     values:{is_ok:false},
  3.     objs:{},
  4.     inputs:{},
  5.     error_codes:{'fio': 'ФИО', 'telephone': 'телефон'},
  6.    
  7.     get_inputs:function()
  8.     {
  9.         var inputs = this.objs['c'].find (':input[type="text"]');
  10.         var tmp = Array();
  11.        
  12.         for (var i in inputs)
  13.         {
  14.             if (inputs[i].name==="" || !inputs[i].name)
  15.             {
  16.                 continue;
  17.             }
  18.            
  19.             name = inputs[i].name;
  20.             tmp[name] = inputs[i];
  21.         }
  22.        
  23.         return tmp;
  24.     },
  25.    
  26.     do_checks:function()
  27.     {
  28.         if (this.inputs['telephone'].value==="")
  29.         {
  30.             this.draw_error (this.inputs['telephone']);
  31.         }
  32.        
  33.         if (this.inputs['fio'].value==="")
  34.         {
  35.             this.draw_error (this.inputs['fio']);
  36.         }
  37.     },
  38.    
  39.    
  40.    
  41.     draw_error:function(input)
  42.     {
  43.         $(input).attr ('style',"border: 3px solid #981a30");
  44.         $('#errors_callback').append ('<p><span style="color:#981a30">Пожайлуста, введите '+this.error_codes[input.name]+'.</span></p>');
  45.        
  46.     },
  47.    
  48.     init:function()
  49.     {
  50.         this.objs['c'] = $("#callback");
  51.         this.inputs = this.get_inputs();
  52.         this.do_checks();
  53.         //this.objs['errors'] = $('#errors_callback');
  54.     }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement