久久机这里只有精品,国产69精品一区二区亚洲孕妇,91精品国产综合久久婷婷香蕉,午夜久久久久久电影

最新活動:電腦PC端+手機端+微網站+自適應網頁多模板選擇-建站388元起價!!!
當前位置:主頁 > 網站建設 > 修改織夢dedecms自定義表單字段為必填項的方法

修改織夢dedecms自定義表單字段為必填項的方法

時間:2023-07-20 13:07:20 閱讀: 文章分類: 網站建設 作者: dede開發者

導讀:織夢教程織夢教程織夢自定義表單用的最多的就是制作留言板,報名等功能,但是添加的字段不填寫就能提交,容易被惡意提交,為了防止這些,我們可以把這些字段選項設定為必填項。dede織夢模板織夢模板安裝。

dede織夢模板織夢模板安裝

織夢自定義表單用的最多的就是制作留言板,報名等功能,但是添加的字段不填寫就能提交,容易被惡意提交,為了防止這些,我們可以把這些字段選項設定為必填項。

方法如下:

1. 用php驗證

在plus/diy.php的第 40行下加    //增加必填字段判斷 if($required!=''){ if(preg_match('/,/', $織夢cms模板required))     {         $requireds = explode(',',$required);         foreach($requireds as $field){             if($$field==''){      &nbs織夢模板安裝p;          showMsg('帶*號的為必填內容,請正確填寫', '-1');                 exit();             }         }     }else{         if($required==''){             showMsg('帶*號的為必填內容,請正確填寫', '-1');             exit();         }     } } //end

2.在模版的表單里加<input type="hidden" name="required" value="name,sex" />

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 styldede免費校板下戰e="width:97%;" cellpadding="0" cellspacing="1"> <tr>   <td align="right" valign="top">姓名:</td>   <td><input type='text' name='name' id='name' style='width:250px'  class='intxt' value='' /> </td> </tr> <tr>   <td align="right" valign="top">性別:</td>   <td><select name='sex' style='width:50px'><option value='男'>男</option> <option value='女'>女</option> </select> </td> </tr> <tr>   <td align="right" valign="top">電話:</td>   <td><input type='text' name='tell' id='tell' 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">備注內容:</td>   <td><input type='text' name='con' id='con' 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>

關鍵詞標簽: 織夢 自定義 字段

聲明: 本文由我的SEOUC技術文章主頁發布于:2023-07-20 ,文章修改織夢dedecms自定義表單字段為必填項的方法主要講述自定義,字段,織夢網站建設源碼以及服務器配置搭建相關技術文章。轉載請保留鏈接: http://www.bifwcx.com/article/web_32227.html

我的IDC 網站建設技術SEOUC.COM
專注網站建設,SEO優化,小程序設計制作搭建開發定制網站等,數千家網站定制開發案例,網站推廣技術服務。
  • 5000+合作客服
  • 8年從業經驗
  • 150+覆蓋行業
  • 最新熱門源碼技術文章

    主站蜘蛛池模板: 江陵县| 琼结县| 昔阳县| 金秀| 巢湖市| 慈溪市| 柘荣县| 正宁县| 阜城县| 定州市| 利辛县| 镇坪县| 色达县| 华安县| 勃利县| 庆城县| 莒南县| 香港| 岱山县| 二连浩特市| 登封市| 昆山市| 越西县| 萝北县| 铜梁县| 当阳市| 遂平县| 民丰县| 桦川县| 黄浦区| 大城县| 郓城县| 西林县| 平凉市| 库尔勒市| 博客| 马边| 桑植县| 江永县| 花莲县| 开远市|