织梦自定义表单必填项修改方法

织梦自定义表单必填项修改方法如下:

用php验证:  

1. 在plus/diy.php 的第 40行下加  

//增加必填字段判断if($required!=''){if(preg_match('/,/', $required))

{



$requireds = explode(',',$required);



foreach($requireds as $field){





if($$field==''){







showMsg('带*号的为必填内容,请正确填写', '-1');







exit();





}



}

}else{



if($required==''){





showMsg('带*号的为必填内容,请正确填写', '-1');





exit();



}

}}//end



2.在模版的表单里加  
value  就是必须字段  多个用 , 隔开。

案例分享:

<form action="/plus/diy.php" enctype="multipart/form-data" method="post"><input name="required" value="name,qq" type="hidden"><input name="action" value="post" type="hidden"><input name="diyid" value="1" type="hidden"><input name="do" value="2" type="hidden"><table style="width:97%;" cellpadding="0" cellspacing="1"><tbody><tr><td align="right" valign="top">姓名:</td><td><input name="name2" id="name2" style="width:250px" class="intxt" type="text"></td></tr><tr><td align="right" valign="top">性别:</td><td><select name="sex2" style="width:50px"><option value="男">男</option><option value="女">女</option></select></td></tr><tr><td align="right" valign="top">电话:</td><td><input name="tell2" id="tell2" style="width:250px" class="intxt" type="text"></td></tr><tr><td align="right" valign="top">地址:</td><td><input name="add" id="add" style="width:250px" class="intxt" type="text"></td></tr><tr><td align="right" valign="top">备注内容:</td><td><input name="con2" id="con2" style="width:250px;height:100px" class="intxt" type="text"></td></tr><input name="dede_fields" value="name2,text;sex2,select;tell2,text;add,text;con2,text" type="hidden"><input name="dede_fieldshash" value="78764e448024ba3607705cbf961ebf3f" type="hidden"></tbody></table><div style="height:30px;padding-top:10px;padding-left:130px;" align="center"><input name="submit" value="提 交" class="coolbg" type="submit"><input name="reset" value="重 置" class="coolbg" type="reset"></div></form>

以上就是在自定义表单里必填项的修改方法,如有别的方法欢迎大家留言交流。

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!
本文关键词:

联系我们

在线咨询:点击这里给我发消息

邮件:w420220301@qq.com