allow ip in url for links

This commit is contained in:
Harry Bomrah 2015-07-06 18:36:14 +08:00
parent 1951c581a2
commit f7c377d092
2 changed files with 8 additions and 1 deletions

View File

@ -38,6 +38,13 @@ var FormValidator = function(form){
}
var reg = new RegExp(/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/);
return reg.test(value);
},
urlwithip : function(value){
if(value == "#"){
return true;
}
var reg = new RegExp(/^https?\:\/\/[^\/\s]+(\/.*)?$/);
return reg.test(value);
}
}

View File

@ -44,7 +44,7 @@
url = "#"
end
%>
<%= n.text_field locale, class:"input-xlarge change", data: {"fv-validation" => "required;url;", "fv-messages" => "Cannot be empty.;Must be valid url.;"}, :value=>url rescue "#" %>
<%= n.text_field locale, class:"input-xlarge change", data: {"fv-validation" => "required;urlwithip;", "fv-messages" => "Cannot be empty.;Must be valid url.;"}, :value=>url rescue "#" %>
<% end %>
</div>
<% end %>