skip to Main Content

I’m trying to make a payment form where user can enter credit/debit card details.
For that I need user to select month and year of expiry of card.
The placeholder of the input date box should show something like this MM/YYYY or MM/YY

<div class="custom-month-input">
    <label for="expiry-date" class="month-placeholder">Expiry(MM/YY)</label>
    <input type="month" id="expiry-date" name="expiry-date">
</div>

I tried mentioning placeholder in input box and giving it a value, but it didn’t work

2

Answers


  1. Since you’re using the input type="month" syntax, I found this:

    <label for="start">Start month:</label>
    
    <input type="month" id="start" name="start" min="2018-03" value="2018-05" />
    

    Code snippet from here: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/month

    This lets the user fill in a number for the date and year, but it’s not entirely intuitive that this is a field in which the user can type numbers.
    It doesn’t seem to support a placeholder value, but you can use a default value as an example

    Login or Signup to reply.
  2.     <input type="month" id="expiry-date" name="expiry-date" placeholder = "">
    

    Does this work? I’ve added placeholder = "" in the code.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search