修改项目发送邮箱时的正则验证

memcached_alan
sw 11 years ago
parent 368a3ce1fa
commit aa8d1741f9

@ -1,14 +1,28 @@
<script> <script>
function verifyAddress() { function verifyAddress() {
var email = $('#mail').val(); var email = $.trim($('#mail').val());
var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if (email == "" || filter.test(email)) { if(email == "")
{
$("#valid_email").html("电子邮件不能为空");
}
else if (filter.test(email)) {
$("#valid_email").html(""); $("#valid_email").html("");
return true;
} }
else else
{ {
$("#valid_email").html("您所填写的电子邮件格式不正确"); $("#valid_email").html("您所填写的电子邮件格式不正确");
} }
return false;
}
function senderEmail(obj)
{
if(verifyAddress())
{
obj.parent().submit();
}
} }
@ -40,10 +54,10 @@
</div> </div>
<%= form_tag('send_mail_to_member', :controller => 'projects',:action => 'send_mail_to_member', method: 'get') do %> <%= form_tag('send_mail_to_member', :controller => 'projects',:action => 'send_mail_to_member', method: 'get') do %>
<span id="valid_email" style="color: #FF0000;"></span> <span id="valid_email" style="color: #FF0000;"></span>
<%= text_field_tag 'mail', '', :class => "fb_item fl", :placeholder => l(:label_input_email), :onblur => "verifyAddress();" %> <%= text_field_tag 'mail', '', :class => "fb_item fl", :placeholder => l(:label_input_email), :onkeyup => "verifyAddress();" %>
<div class="cl"></div> <div class="cl"></div>
<div class="cl"></div> <div class="cl"></div>
<a href="#" class="btn_free" onclick="$(this).parent().submit();"> <a href="#" class="btn_free" onclick="senderEmail($(this));">
<%= l(:label_send_email)%> <%= l(:label_send_email)%>
</a> </a>
<%#= submit_tag '免费发送', :style => "display:block; width:80px; text-align:center; color:#fff; height:26px; padding-top:3px; margin-bottom:10px;" %> <%#= submit_tag '免费发送', :style => "display:block; width:80px; text-align:center; color:#fff; height:26px; padding-top:3px; margin-bottom:10px;" %>

Loading…
Cancel
Save