3

I have a form for which has fields like card no ,card holders name,expiry date and stuff i want something like whenever i am filling the form it should be displayed side by side before storing it to database ,any help?

Mosin Ali
  • 29
  • 6

2 Answers2

1

Bind it to a jQuery keyup event

<form>
  Card No:</br>
  <input type="number">
  <input type="submit" value="submit">
</form>

<p id="display">
</p>

<script>
$(document).ready(function () {
$(":number").keyup(function () { 
$("#display").text($(":number").val());
});
});
</script>
Chris
  • 43
  • 8
  • Thanks that worked for a while until i needed to update using the same form which already has data filled to it so keyup function wont work ? How do i take the value which is already there in the form and display somewhere? – Mosin Ali May 05 '21 at 10:30
1

Here is a really easy solution in vanilla js;

let input = document.getElementById('in');
input.onkeyup = () => {
document.getElementById('p').innerHTML = input.value;
}
<input id='in' type='text'>

<p id='p'></p>
Irfan wani
  • 4,084
  • 2
  • 19
  • 34