Skip to main content
2 of 4
added 84 characters in body
loparr
  • 906
  • 1
  • 14
  • 42

adding js into body

I use drupal 7 an I want to add very simple jquery code to only one page on my site.

 $('#var1').on('keypress keydown keyup', function(){
   $(this).val($(this).val().replace(/([^\d]+)/, '')); 
});
 $('form').submit(


 function (e) {
e.preventDefault();
 var xyz = parseInt($('#var1').val());
$('#result').text("Result is " + ((xyz / 1.25)*30) + " days");
 });

 <form>
<input type="text" id="var1" />
<input type="submit" value="=" />
 </form>
 <span id="result"></span>

The problem is that pressing submit button allways reloads wlole page which I do not need. How to prevent this? Thank you. I need it to work as smooth as this without reloading http://jsfiddle.net/eWXUT/3/

loparr
  • 906
  • 1
  • 14
  • 42