mercredi 27 mai 2015

html input regex pattern not working

<body>
    <form action="" method="post">
        <div>
            <label>First Name: <input type="text" name="firstname" value=" " pattern="[a-zA-Z ]+"></input> </label>
        </div>
        <div>
            <label>Last Name: <input type="text" name="lastname" value="" pattern="[a-zA-Z ]+"> </input> </label>
        </div>
        <div>
            <label>Voucher: <input type="text" name="voucher" value="" pattern="^[0-9]{5}+[-]+[0-9]{5}+[-]+[A-Z]{2}*"></input> </label>
        </div>
        <input type="submit" value="Submit"></input>
    </form>
</body>


^ the above code is my code, first name and last name are all working, the problem is the voucher input does not check the pattern i wanted, it should be like "12345-67890-AB".

Aucun commentaire:

Enregistrer un commentaire