validation for links

This commit is contained in:
Harry Bomrah 2015-06-25 17:02:50 +08:00
parent afde19052e
commit 5acfed083a
2 changed files with 4 additions and 1 deletions

View File

@ -33,6 +33,9 @@ var FormValidator = function(form){
return re.test(value);
},
url : function(value){
if(value == "#"){
return true;
}
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);
}

View File

@ -44,7 +44,7 @@
url = "#"
end
%>
<%= n.text_field locale, class:"input-xlarge change", :value=>url rescue "#" %>
<%= 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 "#" %>
<% end %>
</div>
<% end %>