首页 > 解决方案 > 我如何制作它,以便我可以浏览整个表格?

问题描述

我正在为网站创建一个表单,但现在它只允许我从手机向下切换。我无法从名字到姓氏再到电话。如何更改它以允许我浏览整个内容?

<form data-customer-information-form="true" autocomplete="off" method="POST" action="addticket/submit" name="ticketForm" id="ticketform" accept-charset="UTF-8">
            <p>
                <label for="customerFirstName">First Name:</label></br>
                <input type="text" name="customerFirstName" id="customerFirstName" placeholder="first name" pattern="[A-Za-z]+" required>
            </p>
            <p>
                <label for="customerLastName">Last Name:</label></br>
                <input type="text" name="customerLastName" id="customerLastName" placeholder="last name" required>
            </p>
            <p> 
                <label for="phoneNumber">Phone: used for contact</label></br>
                <input type="tel" id="phone" maxlength="12" name="phoneNumber" placeholder="phone" pattern="[0-9]{3}-[0-9]{3}-[0-9]{4}" required>
            </p>
            <p>
                <label for="email">Email:</label></br>
                <input type="email" name="email" id="email" placeholder="email">
            </p>
            <p>
                <label for="service">Computer/Service Name:</label></br>
                <input type="text" name="service" placeholder="computer model or service" required>
            </p>
            <p>
                <label for="description">Anything else we need to know:</label></br>
                <textarea type="text" maxlength="200" name="description" id="description" placeholder="What's gone wrong?"></textarea>
            </p>
            <input type="submit" name="submit" value="Submit" id="submit">
        </form>

当我将 HTML 复制到 HTML 查看器中时,它工作正常。但在页面的其余部分它停止工作。

标签: htmlforms

解决方案


确保您的 javascript 没有阻止某些键。

document.getElementById("customerFirstName").onkeydown = function(e){
            if(!(e.keyCode === 8 || e.keyCode ===46 || keypress.keyCode === 9)){
            if(!(/[A-Za-z]/i.test(String.fromCharCode(e.keyCode)))) {
            e.preventDefault();
            return false;
            }
            }
        }

推荐阅读