if(string1!=string2.substring(0,string1.length)){
    if(confirm("您输入的信息不一致!")){
        进行处理
    }
}

解决方案 »

  1.   

    <script>
    function checktext()
    {
    if(document.all.mytext2.value.substring(0,document.all.mytext1.value.length)==document.all.mytext1.value)
    form1.submit();
    else
    alert("text2 isn't text1's substring!");
    }
    </script>
    <form name=form1>
    <input name=mytext1>
    <input name=mytext2>
    <input type=button onclick=checktext()>
    </form>
      

  2.   

    sorry,有点小问题。
    楼上的回答已经很完备了
    <script>
    function checktext()
    {
    if(document.all.mytext2.value.substring(0,document.all.mytext1.value.length)==document.all.mytext1.value)
    form1.submit();
    else
    if(confirm("text1 isn't text2's substring!"))
    form1.submit();
    }
    </script>
    <form name=form1>
    <input name=mytext1>
    <input name=mytext2>
    <input type=button onclick=checktext()>
    </form>
      

  3.   

    可为什么我确定后,程序还会提交给后台执行,因为我用的是表单提交jsp进行数据库插入的,您提供的程序在“确定”弹出的对话框后就会继续插入,我该怎么办?
    //好人做到底,我真的深怀感激!
      

  4.   

    if(confirm("text1 isn't text2's substring!"))
    form1.submit();confirm("text1 isn't text2's substring!")
    确定后返回 true 当然就 submit() 了
    最好再加一句
    if(confirm("text1 isn't text2's substring!"))
      form1.submit(); //确定
    else
      mytext1.focuse(); //取消
      

  5.   

    if(confirm("text1 isn't text2's substring!"))
    form1.submit();confirm("text1 isn't text2's substring!")
    确定后返回 true 当然就 submit() 了
    最好再加一句
    if(confirm("text1 isn't text2's substring!"))
      form1.submit(); //确定
    else
      mytext1.focuse(); //取消
      

  6.   

    程序如下:如果要求大小写区分,则把toLowerCase()去掉。<script>
    <!--
    function vdvalue(){
    var frm = document.forms[0];
    var v1=frm.v1.value.toLowerCase();
    var v2=frm.v2.value.toLowerCase();
    var v3=v2.match(/(.*\.)/g);
        v3=v3.toString().replace(/\./g,"");
    if(v1!=v3){
    if(confirm("两个数值不相同,确定要继续吗?!")){
    alert("现在就可以提交到你的表单了!");
    frm.submit();
    }
    }else { alert("输入的数据合乎要求!");
    }
    }
    //-->
    </script>
    <form>
    值一:<input id="v1" name="v1" />
    值二:<input id="v2" name="v2" />
    <input type="button" onclick="vdvalue();" value="提交" />
    </form>
      

  7.   

    if(string1!=string2.substr(0,string1.length))
     {
         if(confirm("您输入的信息不一致!")){
            进行处理
        }
     }