织梦自定义表单验证字段不能为空,绝对实用灵活
来源:互联网 发布:思归软件下载 编辑:程序博客网 时间:2024/06/05 09:17
织梦自定义表单验证字段不能为空,不是通过前台页面js验证,绝对灵活实用。
模板文件的修改:
1、修改diy_field_add.htm,23行左右添加代码
var necessary = theform.necessary[0].checked?theform.necessary[0].value:theform.necessary[1].value;
替换字符串,大概在38行
替换revalue = "<field:"+fieldname+" itemname=\""+itemname+"\" autofield=\"1\" type=\""+dtype+"\" isnull=\""+sisnull+"\" default=\""+vdefault+"\" ";
为revalue = "<field:"+fieldname+" itemname=\""+itemname+"\" autofield=\"1\" type=\""+dtype+"\" isnull=\""+sisnull+"\" necessary=\""+necessary+"\" default=\""+vdefault+"\" ";
2、diy_field_add.htm,大概124行</tr>后面,添加代码
<tr>
<td bgcolor="#FFFFFF">
<strong>是否为必填项:</strong><br/>
<span class="STYLE2">防止恶意提交表单</span>
</td>
<td bgcolor="#FFFFFF">
<input name="necessary" type="radio" value="true" class='np' checked='1' />
是
<input name="necessary" type="radio" value="false" class='np' />
否
</td>
</tr>
3、修改diy_field_edit.htm,18行左右添加代码
var necessary = theform.necessary[0].checked?theform.necessary[0].value:theform.necessary[1].value;
替换字符串,大概在38行
替换revalue += " isnull=\""+sisnull+"\" default=\""+vdefault+"\" ";
为revalue += " isnull=\""+sisnull+"\" necessary=\""+necessary+"\" default=\""+vdefault+"\" ";
4、diy_field_edit.htm,大概139行</tr>后面添加代码
<tr>
<td bgcolor="#FFFFFF"><strong>是否为必填项:</strong><br/>
<span class="STYLE2">防止恶意提交表单</span></td>
<td bgcolor="#FFFFFF">
<input name="necessary" type="radio" value="true"<?PHP if($ctag->GetAtt('necessary')=='true') echo " checked='1' "; ?> class='np' />
是
<input name="necessary" type="radio" value="false"<?php if($ctag->GetAtt('necessary')=='false'||$ctag->GetAtt('necessary')=='') echo " checked='1' "; ?> class='np' />
否 </td>
</tr>
5、表单提交处理:
修改plus/diy.php文件
找到$addvar = $addvalue = '';在上面添加代码
//验证必填字段
$row = $dsql->GetOne("SELECT * FROM `#@__diyforms` WHERE `table`='{$diy->table}'");
$fieldset = $row['info'];
require_once(DEDEINC."/dedetag.class.php");
$dtp = new DedeTagParse();
$dtp->SetNameSpace("field","<",">");
$dtp->LoadSource($fieldset);
if(is_array($dtp->CTags))
{
foreach($dtp->CTags as $tagid=>$ctag)
{
if($ctag->GetAttribute("necessary")=='true' && empty(${$ctag->GetName()}))
{
showmsg($ctag->GetAttribute("itemname")."不能为空!", -1);
exit;
}
}
}
6、这样基本就搞定了,设置参数请通过后台字段编辑设置
文章来源:http://blog.csdn.net/taohaoge/article/details/16963537
- 织梦自定义表单验证字段不能为空,绝对实用灵活
- 织梦自定义表单验证字段不能为空,绝对实用灵活
- JavaScript验证表单项不能为空
- 自己整理 可用的 表单验证(表单项不能为空)js自定义trim操作
- dedecms添加自定义表单判断表单不能为空解决办法
- 通过JS来验证表单项不能为空
- JS判断提交表单不能为空 等的验证
- js简单表单验证,判断不能为空
- 验证表单是否正确——不能为空
- H5表单验证不得为空,自定义提示语
- [PHP]表单验证的字段为空和字段不存在的情况
- 验证表单内容为空
- 验证表单不为空
- DataWindow.NET How To: Data Entry Form(检测表单字段是否不能为空)
- jquery validation表单验证,自定义字段验证
- js循环表单验证,不能为空,和一定要输入数字
- jquey 验证表单是否存在不能为空(ajax+validattion) .
- eXtremeDB 中索引字段不能为空
- jQuery基础篇(一)样式篇
- 自定义标签库
- 2.结构型模式
- Linux下打包压缩war和解压war包
- Eclipse使用git命令行
- 织梦自定义表单验证字段不能为空,绝对实用灵活
- python实现获取天气信息后自动登录邮箱发送到指定邮件联系人
- 【SqlServer】 分享 几个 优化 Sql 的 语句
- Entity SQL 初入
- android新组件
- 能通过一张照片(2D)得到3D的模型吗?
- 微信息小程序 有没有什么办法让小程序tabbar未读消息数的提醒
- 角谷猜想
- sar-0.6--CSK SLC、RS2 SLC、TSX SLC、Sentinel-1 SLC数据解析器安装