输入验证模糊焦点

问题描述 投票:1回答:2

无法正常工作

  <script type="text/javascript">
  //<![CDATA[
  <!--
   function checkPrice(form) {
     var input=0;
     input=document.stickerPrice.value;
        if (input<100000) {               
            alert("Sticker price must be more than $100,000");
            document.getElementsByName("stickerPrice").focus();
    }
 }

       // -->
       //]]>
     </script>

这里是标签部分。

   <form action=''>

    <p>Sticker Price on the Car (in dollars):
    <input type="text" name="stickerPrice" size="15" onblur="checkPrice(this.formData)" /></p>
    </form>

我希望通过onblur事件在警报框小于10,000时出现,然后将焦点放回到该文本框上。

javascript validation input focus onblur
2个回答
1
投票

您可以通过调用本身传递输入


0
投票

我建议您解决方法,并使用onblur删除focus()。

© www.soinside.com 2019 - 2024. All rights reserved.