Home  >  Q&A  >  body text

Date format in HTML form should be "mm/yy"

<p>I want to create an HTML page containing a form, where one cell should be a date in the format 'mm/yy', with the minimum value being the current month (similar to a credit card expiration date). </p> <p>What should I do? I didn't find an option to use a date/month type, is there a better option than using text that matches a regex? </p> <pre class="brush:php;toolbar:false;"><input type="text" pattern="\d{2}/\d{2}" required></pre> </p>
P粉990008428P粉990008428385 days ago535

reply all(1)I'll reply

  • P粉521748211

    P粉5217482112023-09-02 10:07:51

    I recommend using the "date" type. It has a lot of features built into it. You can also set minimum and maximum values. You can find more information here: https://developer.mozilla.org/ru/docs/Web/HTML/Element/Input/date

    Example:

    <input type="date"
       value="2018-07-22"
       min="2018-01-01" max="2018-12-31">

    reply
    0
  • Cancelreply