diff --git a/app/views/feeds/new.html.erb b/app/views/feeds/new.html.erb index b00d715..73e8d0c 100644 --- a/app/views/feeds/new.html.erb +++ b/app/views/feeds/new.html.erb @@ -1,5 +1,19 @@ +<%= javascript_include_tag 'validation' %> +

New feed

+ + <% form_for(@feed) do |f| %> <%= f.error_messages %> @@ -12,8 +26,8 @@ <%= f.text_field :interval %>

- <%= f.submit 'Create' %> + <%= f.submit 'Create', :onClick => 'return verifyFeedURL( feed_url.value );' %>

<% end %> -<%= link_to 'Back', feeds_path %> \ No newline at end of file +<%= link_to 'Back', feeds_path %> diff --git a/db/development.sqlite3 b/db/development.sqlite3 index ca7b629..f21f062 100644 Binary files a/db/development.sqlite3 and b/db/development.sqlite3 differ diff --git a/public/javascripts/validation.js b/public/javascripts/validation.js new file mode 100644 index 0000000..eba4f2a --- /dev/null +++ b/public/javascripts/validation.js @@ -0,0 +1,5 @@ +function isUrl(s) { + var regexp = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/ + return regexp.test(s); +} +