dede自定義表單必填項的方法,織夢文章
導讀:織夢文章織夢文章織夢自定義表單必填項的方法,一般是js來進行驗證判斷,今天就分享下在php里驗證必填項。織夢網站模板dede手機模板。
織夢自定義表單必填項的方法,一般是js來進行驗證判斷,今天就分享下在php里驗證必填項。
用php驗證:
1. 在plus/diy.php 的第40行下加 //增加必填字段判斷 if($required!=''){ if(preg_match('/,/', $required)) { $requireds= explode(',',$required); foreach($requiredsas $field){ if($$field==''){ showMsg('帶*號的為必填內容,請正確填寫','-1'); exit(); } } }else{ if($required==''){ showMsg('帶*號的為必填內容,請正確填寫','-1'); exit(); } } } //end2.在模版的表單里加 <inputtype="hidden" name="required" value="name,qq"/>value 就是必須字段 多個用, 隔開。
案例分享:
<form action="/plus/diy.php"enctype="multipart/form-data" method="post"> <input type="hidden"name="required" value="name,qq" /> <input type="hidden" name="action" value="post"/> <input type="hidden" name="diyid" value="1"/> <input type="hidden" name="do" value="2"/> <table style="width:97%;" cellpadding="0"cellspacing="1"> <tr> <td align="right"valign="top">姓名:</td> <td><input type='text'name='name2' id='name2' style='width:250px' class='intxt' value='' /> </td> </tr> <tr> <td align="right"valign="top">性別:</td> <td><selectname='sex2'style='width:50px'><optionvalue='男'>男</option> <optionvalue='女'>女</option> </select> </td> </tr> <tr> <td align="right"valign="top">電話:</td> <td><input type='text'name='tell2' id='tell2' style='width:250px' class='intxt' value='' /> </td> </tr> <tr> <td align="right"valign="top">地址:</td> <td><input type='text'name='add' id='add' style='width:250px' class='intxt' value='' /> </td> </tr> <tr> <td align="right織夢的模板"valign="t織夢文章模板op">備注內容:</td> <td><input type='text'name='con2' id='con2' style='width:250px;height:100px' class='intxt' value=''/> </td> </tr> <input type="hidden" name="dede_fields"value="name2,text;sex2,select;tell2,text;add,text;con2,text"/> <input type="hidden" name="dede_fieldshash"value="78764e448024ba3607705cbf961ebf3f"/></table> <div align='center'style='height:30px;padding-top:10px;padding-left:130px'> <input type="submit" name="submdede模板堂it" value="提 交"class='coolbg' /> <input type="reset" name="reset" value="重 置"class='coolbg' /> </div> </form>相關織夢網站模板dede手機模板。聲明: 本文由我的SEOUC技術文章主頁發布于:2023-07-21 ,文章dede自定義表單必填項的方法,織夢文章主要講述自定義,表單,織夢網站建設源碼以及服務器配置搭建相關技術文章。轉載請保留鏈接: http://www.bifwcx.com/article/web_32496.html