Get Initial Form Value With Javascript March 31, 2024 Post a Comment I have a php generated form like this Product Name Solution 1: Easiest way is to just save it on document load (unless it's being populated by AJAX or some other post-load event; then you'd have to store the initial state there).<script> $(function(){ var $form = $('form'), formOriginalValue; // store initial state on page load formOriginalValue = $form.serializeArray(); // catch the submit handler and compare $form.submit(function(e){ // given 'element1' is a text box://// original value: formOriginalValue['element1']// new value: $('[name="element1"]', this).val(); }); }); </script>CopySolution 2: Another solution may be to use data-* attributes, jQuery has a built-in data() function in order to manage these data. Baca JugaAdding Html Text To Supersized Jquery Image SlideChanging Div Content With Javascript OnclickHow To Download File In Browser Using Spring Mvc? Share You may like these posts Initialize Javascript In Php Script For A Contact FormJquery Doesn`t Fire/work With My Rails 3.2 ProjectTargeting Specific Text Entered Into Form Input Field And Add Styles To It?How To Display A Bootstrap Modal On Submitting A Form? Post a Comment for "Get Initial Form Value With Javascript"
Post a Comment for "Get Initial Form Value With Javascript"