forked from saurabh/orbit4-5
fixed chinese detection for url.
This commit is contained in:
parent
afe1ffd437
commit
f9dd55eea2
|
@ -44,7 +44,7 @@
|
||||||
url = "#"
|
url = "#"
|
||||||
end
|
end
|
||||||
%>
|
%>
|
||||||
<%= 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 "#" %>
|
<%= n.text_field locale, class:"input-xlarge change", data: {"fv-validation" => "required;urlwithip;detect_chinese;", "fv-messages" => "Cannot be empty.;Must be valid url.;Cannont have chinese.;"}, :value=>url rescue "#" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
@ -14,5 +14,9 @@
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
var fromvalidator = new FormValidator($("form.edit_page"));
|
var fromvalidator = new FormValidator($("form.edit_page"));
|
||||||
|
|
||||||
|
fromvalidator.validate_functions.detect_chinese = function(value){
|
||||||
|
return (value.match(/[\u3400-\u9FBF]/) == null);
|
||||||
|
}
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
|
@ -19,9 +19,10 @@ $(document).ready(function(){
|
||||||
}
|
}
|
||||||
|
|
||||||
fromvalidator.validate_functions.detect_chinese = function(value){
|
fromvalidator.validate_functions.detect_chinese = function(value){
|
||||||
var re1 = new RegExp("^[\u4E00-\uFA29]*$"),
|
// var re1 = new RegExp("^[\u4E00-\uFA29]*$"),
|
||||||
re2 = new RegExp("^[\uE7C7-\uE7F3]*$"); //Chinese character range
|
// re2 = new RegExp("^[\uE7C7-\uE7F3]*$"); //Chinese character range
|
||||||
return (!(re1.test(value) && (! re2.test(value))));
|
// return (!(re1.test(value) && (! re2.test(value))));
|
||||||
|
return (value.match(/[\u3400-\u9FBF]/) == null);
|
||||||
}
|
}
|
||||||
|
|
||||||
fromvalidator.validate_functions.cannot_have_dash = function(value){
|
fromvalidator.validate_functions.cannot_have_dash = function(value){
|
||||||
|
|
Loading…
Reference in New Issue