Here's what I have so far for copying the data from one input field to another:
<p>First Name: <input type="text" name="Afname" onkeyup="copy()"></p>
<p>First Name: <input type="text" name="Bfname"></p>
document.test.Bfname.value = document.test.Afname.value;
And here's what I found online to do the formatting:
// Store the current title value
var title = 'This is a title with a symbol &'
// alert(title); // debug
// Clean up the title
.toLowerCase() // change everything to lowercase
.replace(/^\s+|\s+$/g, "") // trim leading and trailing spaces
.replace(/[_|\s]+/g, "-") // change all spaces and underscores to a hyphen
.replace(/[^a-z0-9-]+/g, "") // remove all non-alphanumeric characters except the hyphen
.replace(/[-]+/g, "-") // replace multiple instances of the hyphen with a single instance
.replace(/^-+|-+$/g, ""); // trim leading and trailing hyphens
alert(url); // outputs 'this-is-a-title-with-a-symbol'
The second code is exactly what I need (see comments) but I don't know how to format the first code to work with the second one. There are scripts online that do this but only after clicking on the submit button. I don't want to click on a submit button. I want the script to work dynamically and format the input field data as I type. Can this be done?
Can someone please help?