我在文本框中生成15位数字的JS代码,我想将生成的数字减少到5或6位数。请帮帮我。在文本框中自动生成的数字
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript">
now = new Date();
randomNum = '';
randomNum += Math.round(Math.random() * 9);
randomNum += Math.round(Math.random() * 9);
randomNum += now.getTime();
window.onload = function() {
document.getElementById("txt_usrid").value = randomNum;
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<input type="text" tooltip="User Id" id="txt_usrid"/>
</div>
</form>
</body>
</html>
检查此链接[小提琴](https://jsfiddle.net/gkzqqt6t/3/)。希望它有效。 –