alert()不用于验证

时间:2017-03-25 21:52:14

标签: javascript html alert

我已尝试添加和删除联系人字段,并将其归结为两个以进行故障排除。我在多个浏览器中尝试过它,但我似乎无法得到警报。只是想指向正确的方向,另一组眼睛可能有所帮助!

这是HTML

xs=[1,2,3,4,5]
old= 2
new=100
new_xs=[1,100,3,4,5]


def replace(xs, old, new, limit=None):
    new_xs=[]
    for num in range(len(xs)):
        if num==old:
            new_xs.append(new)
    return new_xs

这是.JS

<html>
    <head>
        <title> Sugar Shippers International Snacks</title>
        <link rel="stylesheet" type="text/css" href="styletest.css" />
        <script src="/validateInputtesting.js"></script>
    </head>

    <body>

    <div class="container">
    <div class="main">
    <h2>
        Contact us!
    </h2>

    <form action="#" method="post" onsubmit="return ValidateInput()">
        <label>Name: </label>
        <input id="name" name="name" type="text">
        <label>Email: </label>
        <input id="email" name="email" type="text">
        <input type="submit" value="Lets Go"
        </form>
        </div>
        </div>
    </body>
</html>

1 个答案:

答案 0 :(得分:0)

添加&gt;到这一行的结尾:

<input type="submit" value="Lets Go"

对于验证,我个人会这样做:

<input id="email" type="email" name="email" placeholder="Email" required pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$">