destoon 信息发布表单提交验证

  2020-02-07    阅读:169
 sell 模块的form表单如下:

<form method=http://www.baihang8899.com/skin/gw/image/nopic.gifposthttp://www.baihang8899.com/skin/gw/image/nopic.gif id=http://www.baihang8899.com/skin/gw/image/nopic.gifdformhttp://www.baihang8899.com/skin/gw/image/nopic.gif action=http://www.baihang8899.com/skin/gw/image/nopic.gif?http://www.baihang8899.com/skin/gw/image/nopic.gif target=http://www.baihang8899.com/skin/gw/image/nopic.gifsendhttp://www.baihang8899.com/skin/gw/image/nopic.gifhttp://www.baihang8899.com/skin/gw/image/nopic.gifreturn check();http://www.baihang8899.com/skin/gw/image/nopic.gif>

 

<tr>

        <td class=http://www.baihang8899.com/skin/gw/image/nopic.giftlhttp://www.baihang8899.com/skin/gw/image/nopic.gif><span class=http://www.baihang8899.com/skin/gw/image/nopic.giff_redhttp://www.baihang8899.com/skin/gw/image/nopic.gif>*</span> 行业分类</td>

        <td class=http://www.baihang8899.com/skin/gw/image/nopic.giftrhttp://www.baihang8899.com/skin/gw/image/nopic.gif><div id=http://www.baihang8899.com/skin/gw/image/nopic.gifcateschhttp://www.baihang8899.com/skin/gw/image/nopic.gif></div>

          {ajax_category_select('post[catid]', '选择分类', $catid, $moduleid, $DT_TOUCH ? '' : 'size=http://www.baihang8899.com/skin/gw/image/nopic.gif2http://www.baihang8899.com/skin/gw/image/nopic.gif style=http://www.baihang8899.com/skin/gw/image/nopic.gifheight:120px;width:180px;http://www.baihang8899.com/skin/gw/image/nopic.gif')}&#123;if !$DT_TOUCH&#125;<br/>

          &#123;/if&#125;&#123;if $DT[schcate_limit]&#125;&#123;/if&#125;<span id=http://www.baihang8899.com/skin/gw/image/nopic.gifdcatidhttp://www.baihang8899.com/skin/gw/image/nopic.gif class=http://www.baihang8899.com/skin/gw/image/nopic.giff_redhttp://www.baihang8899.com/skin/gw/image/nopic.gif></span></td>

</tr>

 

 

 

表单验证函数 check()

&#123;if $action == 'add' || $action == 'edit'&#125; 

  <script type=http://www.baihang8899.com/skin/gw/image/nopic.giftext/javascripthttp://www.baihang8899.com/skin/gw/image/nopic.gif>

function _p() {

if(Dd('tag').value) {

Ds('reccate');

}

}

function check() {

var l;

var f;

f = 'catid_1';     //存储分类id的隐藏表单 

if(Dd(f).value == 0) {

Dmsg('请选择所属分类', 'catid', 1);   //Dmsg 函数在/file/script/common.js  函数详细介绍传送门

return false;

}

f = 'title';

l = Dd(f).value.length;

if(l < 2 || l > 30) {

Dmsg('信息标题应为2-30字,当前已输入'+l+'字', f);    //在dtitle标签显示提示 并且不滚动到dtitle标签,

                                                                                    //如果想要滚动到 用Dmsg('信息标题应为2-30字,当前已输入'+l+'字', f,1); 

return false;

}

&#123;if $MOD[upload_thumb] && $MG[upload]&#125;

f = 'thumb';

l = Dd(f).value.length;

if(l < 5) {

Dmsg('请上传第一张产品图片', f);   

return false;

}

&#123;/if&#125;

&#123;if !$_userid&#125;

f = 'company';

l = Dd(f).value.length;

if(l < 2) {

Dmsg('请填写公司名称', f);

return false;

}

if(Dd('areaid_1').value == 0) {

Dmsg('请选择所在地区', 'areaid');

return false;

}

f = 'truename';

l = Dd(f).value.length;

if(l < 2) {

Dmsg('请填写联系人', f);

return false;

}

f = 'mobile';

l = Dd(f).value.length;

if(l < 7) {

Dmsg('请填写手机', f);

return false;

}

&#123;/if&#125;

&#123;if $FD&#125;{fields_js()}&#123;/if&#125;

&#123;if $CP&#125;{property_js()}&#123;/if&#125;

&#123;if $need_password&#125;

f = 'password';

l = Dd(f).value.length;

if(l < 6) {

Dmsg('请填写支付密码', f);

return false;

}

&#123;/if&#125;

&#123;if $need_question&#125;

f = 'answer';

l = Dd(f).value.length;

if(l < 1) {

Dmsg('请填写验证问题', f);

return false;

}

if(Dd('c'+f).innerHTML.indexOf('error') != -1) {

Dd(f).focus();

return false;

}

&#123;/if&#125;

&#123;if $need_captcha&#125;

f = 'captcha';

l = Dd(f).value;

if(!is_captcha(l)) {

Dmsg('请填写正确的验证码', f);

return false;

}

if(Dd('c'+f).innerHTML.indexOf('error') != -1) {

Dd(f).focus();

return false;

}

&#123;/if&#125;

return true;

}

var destoon_oauth = '&#123;&#36;EXT[oauth]&#125;';

</script> 

  &#123;/if&#125;

 

 

 Dmsg 函数详情

//Dmsg 函数在/file/script/common.js

//str-提示信息

//i-需要验证表单id ,例如 catid,title

//s-滚动到提示表单位置的开关 1-滚动,0-不滚动,提示信息是显示到id名为“d”+i的标签里的,所以页面上必须有个 dcatid 和 dtitle才行

//t-显示提示信息的时间,显示一会后会自动隐藏

function Dmsg(str, i, s, t) {

 

var t = t ? t : 5000; //t的默认值是5000,如果没有传t参数则默认5000毫秒。

       var s = s ? 1 : 0;    //s的默认值是0

       var h = i == 'content' ? 450 : 50;  //表单高度 

try{

if(typeof Dbrowser != 'undefined') {alert(str);return;} 

if(s || i == 'content')&#123;&#36;(http://www.baihang8899.com/skin/gw/image/nopic.gifhtml, bodyhttp://www.baihang8899.com/skin/gw/image/nopic.gif).animate({scrollTop:$('#d'+i).offset().top-h&#125;, 100);}

Dd('d'+i).innerHTML = '<img src=http://www.baihang8899.com/skin/gw/image/nopic.gif'+SKPath+'image/check_error.gifhttp://www.baihang8899.com/skin/gw/image/nopic.gif width=http://www.baihang8899.com/skin/gw/image/nopic.gif12http://www.baihang8899.com/skin/gw/image/nopic.gif height=http://www.baihang8899.com/skin/gw/image/nopic.gif12http://www.baihang8899.com/skin/gw/image/nopic.gif align=http://www.baihang8899.com/skin/gw/image/nopic.gifabsmiddlehttp://www.baihang8899.com/skin/gw/image/nopic.gif/> '+str+sound('tip');

Dd(i).focus();

 

}catch(e){}

window.setTimeout(function(){Dd('d'+i).innerHTML = '';}, t);

}

 

destoon 升级了 dmsg函数  但是这个函数也不好用

 

function Dmsg(str, i, s, t) { 

var t = t ? t : 5000; var s = s ? true : false;

try{if(s){window.scrollTo(0,0);}Dd('d'+i).innerHTML = '<img src=http://www.baihang8899.com/skin/gw/image/nopic.gif'+SKPath+'image/check_error.gifhttp://www.baihang8899.com/skin/gw/image/nopic.gif width=http://www.baihang8899.com/skin/gw/image/nopic.gif12http://www.baihang8899.com/skin/gw/image/nopic.gif height=http://www.baihang8899.com/skin/gw/image/nopic.gif12http://www.baihang8899.com/skin/gw/image/nopic.gif align=http://www.baihang8899.com/skin/gw/image/nopic.gifabsmiddlehttp://www.baihang8899.com/skin/gw/image/nopic.gif/> '+str+sound('tip');Dd(i).focus();}catch(e){}

window.setTimeout(function(){Dd('d'+i).innerHTML = '';}, t);

}

免责声明:
本站部份内容系网友自发上传与转载,不代表本网赞同其观点;
如涉及内容、版权等问题,请在30日内联系,我们将在第一时间删除内容!

相关Destoon技术

(c)2012-2020 www.destoon.info All Rights Reserved
慧一科技工作室   
  QQ咨询

购买模板 售前咨询

  咨询QQ

3292628658
(早8:30-晚10:00)

  微信咨询

咨询微信
客服微信

  返回顶部