【发布时间】:2017-05-03 09:40:53
【问题描述】:
我在文本框中生成 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>
【问题讨论】:
-
查看此链接fiddle。希望它有效。
标签: javascript jquery asp.net json