校园春色亚洲色图_亚洲视频分类_中文字幕精品一区二区精品_麻豆一区区三区四区产品精品蜜桃

主頁 > 網(wǎng)站建設(shè) > 建站知識(shí) > dede自定義表單必填項(xiàng)的方法

dede自定義表單必填項(xiàng)的方法

POST TIME:2020-03-31 13:31

織夢(mèng)自定義表單必填項(xiàng)的方法,一般是js來進(jìn)行驗(yàn)證判斷,今天就分享下在php里驗(yàn)證必填項(xiàng)。

用php驗(yàn)證:

1. 在plus/diy.php 的第40行下加
//增加必填字段判斷 if($required!=''){ if(preg_match('/,/', $required)) { $requireds= explode(',',$required); foreach($requiredsas $field){ if($$field==''){ showMsg('帶*號(hào)的為必填內(nèi)容,請(qǐng)正確填寫','-1'); exit(); } } }else{ if($required==''){ showMsg('帶*號(hào)的為必填內(nèi)容,請(qǐng)正確填寫','-1'); exit(); } } } //end


2.在模版的表單里加 <inputtype="hidden" name="required" value="name,qq"/>
value 就是必須字段 多個(gè)用, 隔開。

案例分享:

<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="top">備注內(nèi)容:</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="submit" value="提 交"class='coolbg' /> &nbsp; <input type="reset" name="reset" value="重 置"class='coolbg' /> </div> </form>



收縮
  • 微信客服
  • 微信二維碼
  • 電話咨詢

  • 400-1100-266
主站蜘蛛池模板: 新泰市| 正定县| 刚察县| 仙游县| 根河市| 阿合奇县| 英德市| 托里县| 广安市| 酒泉市| 丹江口市| 华宁县| 定远县| 修水县| 宜章县| 明星| 会泽县| 招远市| 宽甸| 宁德市| 甘德县| 新密市| 西昌市| 丹寨县| 黄梅县| 湖南省| 濮阳市| 遂昌县| 抚顺县| 读书| 海阳市| 无锡市| 恭城| 凤阳县| 云南省| 柳州市| 称多县| 洮南市| 溧水县| 大丰市| 青田县|