解决方案 »

  1.   


    能给写个text文本框使用样例么。
      

  2.   


    能给写个text文本框使用样例么。
    swing的界面我就不写了JTextField text=new JTextField();
    String content=text.getText();
    if(content.matches("([01][0-9]|2[0-3]):[0-5][0-9]-([01][0-9]|2[0-3]):[0-5][0-9] "))
       JOptionPane.showMessageDialog(null, "格式不正确", "error", JOptionPane.ERROR_MESSAGE);web的使用jquery<script>
      if( /^([01][0-9]|2[0-3]):[0-5][0-9]-([01][0-9]|2[0-3]):[0-5][0-9]$/.test($.trim($("#text").val()))){
         alert("格式不正确");
      }
    </script>
    <input id="text"/>
      

  3.   


    能给写个text文本框使用样例么。
    swing的界面我就不写了JTextField text=new JTextField();
    String content=text.getText();
    if(content.matches("([01][0-9]|2[0-3]):[0-5][0-9]-([01][0-9]|2[0-3]):[0-5][0-9] "))
       JOptionPane.showMessageDialog(null, "格式不正确", "error", JOptionPane.ERROR_MESSAGE);web的使用jquery<script>
      if( /^([01][0-9]|2[0-3]):[0-5][0-9]-([01][0-9]|2[0-3]):[0-5][0-9]$/.test($.trim($("#text").val()))){
         alert("格式不正确");
      }
    </script>
    <input id="text"/>
    能不能在<input>标签里用 onkeyup="value=value.replace(/[^0-9]/g,'')" 类似这样的方法写呢?
      

  4.   


    能给写个text文本框使用样例么。
    swing的界面我就不写了JTextField text=new JTextField();
    String content=text.getText();
    if(content.matches("([01][0-9]|2[0-3]):[0-5][0-9]-([01][0-9]|2[0-3]):[0-5][0-9] "))
       JOptionPane.showMessageDialog(null, "格式不正确", "error", JOptionPane.ERROR_MESSAGE);web的使用jquery<script>
      if( /^([01][0-9]|2[0-3]):[0-5][0-9]-([01][0-9]|2[0-3]):[0-5][0-9]$/.test($.trim($("#text").val()))){
         alert("格式不正确");
      }
    </script>
    <input id="text"/>
    能不能在<input>标签里用 onkeyup="value=value.replace(/[^0-9]/g,'')" 类似这样的方法写呢?
    楼主到底想问什么
      

  5.   


    就是一个text框,我想做输入限制。之前都是用的onkeyup失去焦点时候判断。所以惯性想偷个懒。
    你写的例子我放代码里,没起作用。。
      

  6.   

    那你鼠标失去焦点
     if( /^([01][0-9]|2[0-3]):[0-5][0-9]-([01][0-9]|2[0-3]):[0-5][0-9]$/.test($.trim($("#text").val()))){
         alert("格式不正确");
      }这个可以的。