I need to validate that the the user has entered a ten digit number into the text box, and need some help with the code.
Here is what I have:

<title>Checking with RegExp</title>
<script type="text/javascript">
function checknumber() {
var tendigitnum = document.getElementById("text").value;
var check=/^\d{10}$/;
if (check.test(tendigitnum)) {
window.alert("You entered"+tendigitnum);
else {
window.alert("Please enter a valid 10 digit number");
<form method="post" name="submitnumber" onsubmit="checknumber()">
<input type="text" id="text" name="inputnumber" size="15"></input>
<input name="check" value="Check" type="submit"></input>