Project

General

Profile

Patch #13763 » check_hostname_setting_v2.diff

Version 2 - Daniel Felix, 2013-04-14 20:55

View differences:

app/views/settings/_general.html.erb
1
<% content_for :header_tags do %>
2
  <%= javascript_tag do %>
3
  var timer;
4
  
5
  function validateInputfield(id,regexp){
6
    var regexp = new RegExp(regexp); 
7
    
8
    if(regexp.test($(id).val())){
9
      $(id).removeClass('invalid').addClass('valid');
10
      return true;
11
    }
12
    else{
13
      $(id).removeClass('valid').addClass('invalid');
14
      return false;
15
    }
16
  };
17
  
18
  $('#settings_host_name').live("keypress", function(){
19
    clearTimeout(timer);
20
    
21
    timer  = setTimeout(function(){
22
      validateInputfield('#settings_host_name','^[^0-9\:\./]+(([^/:@])||(:[0-9]+))+$');
23
    },500);
24
  });
25
  $(document).ready(function(){
26
    validateInputfield('#settings_host_name','^[^0-9\:\./]+(([^/:@])||(:[0-9]+))+$');
27
  });
28
  
29
  <% end %>
30
<% end %>
31

  
1 32
<%= form_tag({:action => 'edit'}) do %>
2 33

  
3 34
<div class="box tabular settings">
public/stylesheets/application.css
584 584
  background-image: url(../images/loading.gif);
585 585
}
586 586

  
587
input.valid, input.invalid{padding-left:25px !important}
588
input.valid{background:#fff url("../images/true.png") no-repeat 2px 50%}
589
input.invalid{background:#fff url("../images/false.png") no-repeat 2px 50%}
590

  
587 591
/***** Flash & error messages ****/
588 592
#errorExplanation, div.flash, .nodata, .warning, .conflict {
589 593
  padding: 4px 4px 4px 30px;
(2-2/3)