var somefunction=function(){
            if(错误)
{
alert();
return false;
}
        return true;
        };OnClientClick="return somefunction()" 

解决方案 »

  1.   

    作下参考function check()
    {
    if(!document.form1.title.value) {
    alert('标题不能为空!');
    }
    else { 
    document.form1.submit();
    }
    }<form id='form1' name='form1' method='get'>
    <input type="text" name="title" id="title"/>
    <input type="button" value="提交" onclick="check();" />
    </form>
      

  2.   


    <script type="text/javascript">
    function check()
    {
    if(!document.form1.title.value) {
    alert('标题不能为空!');
    }
    else { 
    document.form1.submit();
    }
    }
    </script><form id='form1' name='form1' method='get'>
    <input type="text" name="title" id="title"/>
    <input type="button" value="提交" onclick="check();" />
    </form>