Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

95
Views
Javascript - Duplicate Field input

I'm trying to duplicate a field input like this in JSFiddle

But when I save the below in a html file, it is not working.

Can someone please assist?

<html>

<head>
<script>
$(function() { // <== Doc Ready
  $("#email").change(function() { // When email is changed
    $('#mail').val(this.value); // copy it over to mail
  });
});
</script>
</head>

<body>
<input type="text" name="email" id="email" />
<input type="text" name="mail" id="mail" />
</body>

</html>
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Your function is working as expected.

The only issue with your code was the jQuery was not loaded to the snippet.

But instead of change, if you use keyup or input, you could see the changes right on time

Change will be triggered only when you focus away from your input.

$(function() { // <== Doc Ready
  $("#email").on('keyup', function() { // When email is changed
    $('#mail').val(this.value); // copy it over to mail
  });
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input type="text" name="email" id="email" />
<input type="text" name="mail" id="mail" />

about 4 years ago · Juan Pablo Isaza Report

0

This code will run for sure.

$(document).ready(function() {
    $('#email').keyup(function(e){
    $('#mail').val(e.target.value);
  })
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input type="text" name="email" id="email" />           
<input type="text" name="mail" id="mail"/>

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!