I have the solution to my question but I wanted to see if anyone can help me understand why this is happening. When I submit a form with I am unable to set the value of the text field using jQuery in the submit event handler. However when I use I can change text field values using jQuery val() method.
HTML and JS code is below:
<form>
<span> Enter the decimal digit to convert the value</span>
<input type="text" id="num"/>
<input type="submit" id="subbtn" value="Submit"/>
</form>
$(document).ready( function () {
//Search the parent class, id, or tag and then try to find the <a id="addMore"></a> as a child
$('#subbtn').on('click',function () {
$("#num").val('XYZ');
});
});
The code above does not work. It only works when I change the button input type to “button” instead of “submit”. When I use SUBMIT the input value changes for a few seconds and then disappears.
Thank you for your time and help.
Ramya