How do i create a live form which can display whatever i fill side by side in a design?

Viewed 64

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?

2 Answers

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>

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>

Related