Discuz!X2.0限制中文、英文和數字注冊的方法
來源:程序員人生 發布時間:2013-11-04 20:57:24 閱讀次數:5433次
Discuz!論壇程序是我們非常喜歡的論壇社區程序,而最近推出的Discuz! X2.0正式版更是功能豐富的不得了,但是在一些小的細節上來說,處理的還不是太好,畢竟一個產品的完美程度是有限的,今天學院小編就來跟大家討論一下如何實現Discuz!X2.0限制中文、英文和數字注冊的問題。
一。只允許輸入使用中文注冊的方法
打開:template----default----member----register.htm 如使用的不是默認風格 就找你使用的風格包里
查找:
<div class="rfm">
<table>
<tr>
<th><span class="rq">*</span><label for="{$this->setting['reginput']['username']}">{lang username}:</label></th>
<td><input type="text" id="{$this->setting['reginput']['username']}" name="" class="px" tabindex="1" autocomplete="off" size="25" maxlength="15" required /></td>
<td class="tipcol"><i id="tip_{$this->setting['reginput']['username']}" class="p_tip">{lang register_username_tips}</i><kbd id="chk_{$this->setting['reginput']['username']}" class="p_chk"></kbd></td>
</tr>
</table>
</div>
修改為:
<div class="rfm">
<table width="50%">
<tr>
<th>友情提示:本論壇 『 <font color=red>只接受中文注冊</font> 』用戶名*</th>
</tr>
</table>
</div>
<div class="rfm">
<table>
<tr>
<th><span class="rq">*</span><label for="{$this->setting['reginput']['username']}">{lang username}:</label></th>
<td><input type="text" id="{$this->setting['reginput']['username']}" name="" class="px" tabindex="1" autocomplete="off" size="25" maxlength="15" onpropertychange="with(this)if(/[^u3447-uFA29]/ig.test(value))value=value.replace(/[^u3447-uFA29]/ig,'')" required /></td>
<td class="tipcol"><i id="tip_{$this->setting['reginput']['username']}" class="p_tip">{lang register_username_tips}</i><kbd id="chk_{$this->setting['reginput']['username']}" class="p_chk"></kbd></td>
</tr>
</table>
</div>
二。只允許輸入英文注冊的方法
上面代碼中的紅色部分,替換為:
onkeyup="this.value=this.value.replace(/[^a-z|A-Z]/g,'')" onblur="this.value=this.value.replace(/[^a-z|A-Z]/g,'')"
三。只允許輸入數字注冊的方法
上面代碼中的紅色部分,替換為:
onkeyup="value=value.replace(/[^d]/g,'') "onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^d]/g,''))"