我正在尝试创建一个登录表单,输入员工 ID、密码并提交。例如,软件有一个序列号,只有当它与软件所需的序列号的模式或格式匹配时才会被接受。我该怎么做?我希望它有一个缩略图,它会弹出并告诉你这不是正确的格式,比如 <b>required</b>
。当你输入 <b>input</b>
时会发生什么标签。我还希望能够为缩略图设置样式,以使其与网站的 UI 相匹配。
html 格式:
<section name="LoginSection" id="LoginSection" class="LoginSection">
<div name="LoginHeader" id="LoginHeader" class="LoginHeader">
<center><h3>Staff Login</h3></center>
</div>
<form name="LoginForm" id="LoginForm" class="LoginForm" action="">
<input type="text" placeholder="Staff Identification Number" name="StaffInput" id="StaffInput" class="StaffInput" required />
<input type="password" placeholder="Staff Login Password" name="StaffPass" id="StaffPass" class="StaffPass" required />
<center><input type="submit" value=" Submit " name="Submit" id="Submit" class="Submit" /></center>
</form>
</section>
最佳答案
尝试更多关于 HTML5 的东西:
<input type="tel" name="mobileno" pattern="[789][0-9]{9}" required title="Enter Mobileno in correct format"/>
或者如果你想使用 Javascript 之类的东西:
<script type="text/javascript">
function login()
{
if(document.loginFrm.mobileno.value.length==0 )
{
alert('Enter MobileNo please');
document.loginFrm.mobileno.focus()
}
//return false
}
</script>
关于javascript - 在登录表单中输入员工ID时如何制作某种模式或算法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21770609/