budimir Posted September 16, 2008 Share Posted September 16, 2008 Hey Guys, I'd like when a user enters a date that it's displayes in two different input boxes. I have tried searching on google but only thing I come up is that I can display it in alert box. This is the code I found, but it's not suting my needs. <script type="text/javascript"> function notEmpty(){ var myTextField = document.getElementById('myText'); if(myTextField.value != "") alert("You entered: " + myTextField.value) else alert("Would you please enter some text?") } </script> <input type='text' id='myText' /> <input type='button' onclick='notEmpty()' value='Form Checker' /> So, I want. In input box1 user enters a date and at the same moment that date is displayed in input box2. Any solutions? You can point me to the web page that can help me!! Thanks. Quote Link to comment Share on other sites More sharing options...
uniflare Posted September 17, 2008 Share Posted September 17, 2008 I believe you want to take a look at the OnKeyPress/KeyDown/KeyUp Events. With it you can update elements on screen when they type into a text box, like this simple function: <script type="text/javascript"> // Function Called "copyfield" Arguments: (Copy From,Copy To,Within Form...) function copyfield(field,mirror,formblock){ // Shortcut to the Form element' Namespace with(formblock){ // Shortcut and Store the new textbox value with(field){ var cText = value; } // Shortcut and copy the stored value to the mirror text box with(mirror){ value = cText; } } } </script> <form name="form1" id="form1"> <input type='text' name='dobinput' onkeyup='copyfield(dobinput,mirrorinput,form1)' value='Date of Birth' /> -- <input type='text' name='mirrorinput' disabled> </form> The function can be used with any fields, can update any field from any field as long as they are in the same form block. Hope this helps Quote Link to comment Share on other sites More sharing options...
budimir Posted September 17, 2008 Author Share Posted September 17, 2008 Thanks. I'll try it out and let you know if everything is OK. Thank you very much. Quote Link to comment Share on other sites More sharing options...
budimir Posted September 17, 2008 Author Share Posted September 17, 2008 @uniflare Thanks, so much. It's exactly what I have been looking for. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.