javascript中的Reg Exp

javascript中的Reg Exp,javascript,regex,Javascript,Regex,我需要填写一个文本框,两个数字之间用“-”隔开示例5-3 23-12 如何对这些数字和分隔符一起执行检查(reg exp) <form id="myForm" method="post"> <input type="text" name="entered"><br> <input type="button" value="Submit" onclick="buttonLogic()"><br> <select id="selec

我需要填写一个文本框,两个数字之间用“-”隔开示例5-3 23-12 如何对这些数字和分隔符一起执行检查(reg exp)

<form id="myForm"  method="post">
<input type="text" name="entered"><br>
<input type="button" value="Submit" onclick="buttonLogic()"><br>
<select id="selector">
</select>
</form>



需要一些帮助只是为了RegExp


谢谢

我想您有一个输入元素。对文本框的值使用正则表达式。 例如,如果您的输入具有id“box”

var boxValue = document.getElementById('box').value.match(/(\d+)-(\d+)/)
您将获得一个包含以下内容的数组: -框值 -第一个数字
-第二个数字

你可以试试这个正则表达式:
/^(\d+)-(\d+)$/

你不应该假设他在使用jQuery,问题中没有提到它,这帮了大忙!非常感谢:)