Sunday, May 12, 2024
 Popular · Latest · Hot · Upcoming
128
rated 0 times [  135] [ 7]  / answers: 1 / hits: 21374  / 10 Years ago, mon, december 8, 2014, 12:00:00

I have a HTML5 form as follows, which is styled with Bootstrap3 and contains a range input and a number input. The two inputs are linked so that whenever I change the range value, the number input is updated and vice versa.



What's bothering me is that when I change the number input value and hit the Enter key, the whole web page reloads and this wipes out all other data loaded into the page with JavaScript.



My questions is, how can I change the HTML/code to disable this reloading behavior?



Thanks.



    <form class=form-horizontal>
<div class=form-group>
<div class=col-xs-6>
<input type=range class=policy_slider name=demandRange min=0.1 max=10 value=1 oninput=this.form.demandInput.value=this.value/>
</div>
<div class=col-xs-1>
<input type=number name=demandInput min=0.1 max=10 value=1 step=any oninput=this.form.demandRange.value=this.value/>
</div>
</div>
</form>

More From » html

 Answers
14

Set the form submit to use javascript and return false. Afterwards, you can use another function to do the actual submit.



<form class=form-horizontal onSubmit=return false;>


JSFIDDLE: http://jsfiddle.net/biz79/m3veL3uh/


[#68546] Friday, December 5, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jazminkyrap

Total Points: 631
Total Questions: 89
Total Answers: 109

Location: Finland
Member since Fri, Oct 21, 2022
2 Years ago
;