javascript中有判断子串是否存在的函数。indexof()(我的大小谢很可能有问题。)
a="abc同意";
i=a.indexof("同意");
if i=0
  无“同意“

解决方案 »

  1.   

    <html>
    <head>
    <script>
    </script>
    function form_onsubmit()
    {
        // 如果文本框中有同意
        if ( document.forms[0].txt.value.indexOf('同意') != -1 )
        {
            // 提交表单
            return true;
        }
        else // 文本框值为空
        if ( document.forms[0].txt.value == '' )
        {
            // 设置文本框值为 '同意'
            document.forms[0].txt.value = '同意';
            // 提交表单
            return true;
        }    // 其他情况不提交
        return false;
    }
    </head>
    <body>
    <form method=post onsubmit="return form_onsubmit()">
    <input type=text name=txt>
    <input type=submit name=upd value=提交>
    </form>
    </body>
    </html>