第一步:
修改 /templets/plus/post_diyform.htm 添加以下代码(建议放到body标签里、form后边):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | < script type = "text/javascript" src = "/images/js/j.js" ></ script > < script type = "text/javascript" > function chk(){ var checked = true; if(checked){ $('#form input').each(function(i,e){ if($(this).val() == ''){ var tip = $(this).parents('tr').children('td').eq(0).html().replace(':',''); alert('请填写 '+tip+' !'); $(this).focus(); checked = false; return false; } }); } if(checked){ $('#form textarea').each(function(i,e){ if($(this).val() == ''){ var tip = $(this).parents('tr').children('td').eq(0).html().replace(':',''); alert('请填写 '+tip+' !'); $(this).focus(); checked = false; return false; } }); } if(checked){ return true; }else{ return false; } } </ script > |
第二步:
给form添加 onsubmit=”return chk();”
<完>