app/views/settings/_general.html.erb | 31 +++++++++++++++++++++++++++++++ public/stylesheets/application.css | 4 ++++ 2 files changed, 35 insertions(+) diff --git a/app/views/settings/_general.html.erb b/app/views/settings/_general.html.erb index 4ec0199..27be6e9 100644 --- a/app/views/settings/_general.html.erb +++ b/app/views/settings/_general.html.erb @@ -1,3 +1,34 @@ +<% content_for :header_tags do %> + <%= javascript_tag do %> + var timer; + + function validateInputfield(id,regexp){ + var regexp = new RegExp(regexp); + + if(regexp.test($(id).val())){ + $(id).removeClass('invalid').addClass('valid'); + return true; + } + else{ + $(id).removeClass('valid').addClass('invalid'); + return false; + } + }; + + $('#settings_host_name').live("keypress", function(){ + clearTimeout(timer); + + timer = setTimeout(function(){ + validateInputfield('#settings_host_name','^[^0-9\:\./]+(([^/:@])||(:[0-9]+))+$'); + },500); + }); + $(document).ready(function(){ + validateInputfield('#settings_host_name','^[^0-9\:\./]+(([^/:@])||(:[0-9]+))+$'); + }); + + <% end %> +<% end %> + <%= form_tag({:action => 'edit'}) do %>