javascript - 在登录表单中输入员工ID时如何制作某种模式或算法?

标签 javascript html css

我正在尝试创建一个登录表单,输入员工 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/

相关文章:

javascript - 如何通过单击一次销毁命名的 jquery-styles?

javascript - 如何使用onchange事件?

html - 覆盖 Bootstrap 3.0

javascript - 在javascript的音频缓冲过程中用 "loading"替换文本?

javascript - 如何使用 x-init 使用 AlpineJS 设置下拉选项的 'selected' 属性

javascript - 从不谈论填充普通 View

javascript - 尽管被设置为特定 IP,但 socket.io 引用本地主机

html - 如何获得 HTML 浏览按钮来过滤和仅显示图像?

javascript - 使用 JavaScript 从 XML 文件搜索并输出数据

twitter-bootstrap - Bootstrap 4 : Dropdown menu is going off to the right of the screen