-1

i want javascript live read my input field by "id" because payment gateway not allow to add name in input field

formSelectors: {
              numberInput: 'input[name="number"]',
              expiryInput: 'input[name="expiry"]',
              cvcInput: 'input[name="cvc"]',
              nameInput: 'input[name="name"]';
            }
M.Nadeem
  • 67
  • 7

2 Answers2

1

Quick answer:

formSelectors: {
              numberInput: '#yourInputId'
            }

In addition:

other options to get element by id:

document.getElementById("yourInputId")

Plus every element that has Id is already selected by JavaScript and stored in variables with same names as id. for example

<div id="myid"></div>

You will have variable myid in javascript and can use it

console.log (myid.classList) // array of classes
qiAlex
  • 4,290
  • 2
  • 19
  • 35
0

finally i got solution here is so simple change name to id

formSelectors: {
          numberInput: 'input[id="number"]',
          expiryInput: 'input[id="expiry"]',
          cvcInput: 'input[id="cvc"]',
          nameInput: 'input[id="name"]'
        }
M.Nadeem
  • 67
  • 7