Questions tagged [preventdefault]

Javascript event method to cancel the event if it is cancelable, without stopping further propagation of the event.

Javascript event method to cancel the event if it is cancelable, without stopping further propagation of the event.

960 questions
-1
votes
2 answers

How to restrict keyboard key events in web application?

I am doing the secured web application. My client requirement is to don't allow the application to refresh using the F5 . Also to restrict events of the Esc , Backspace keys. I am using the jQuery 1.9.1. My code is given below. I can get the alert,…
Human Being
  • 8,269
  • 28
  • 93
  • 136
-1
votes
1 answer

An AJAX method I am trying to use is disabling another jQuery method

This chunk of AJAX $('input#adminLogin').on('submit', function() { var username = $('#username').val(); var password = $('#password').val(); if (username == '' || password == '') …
Monica
  • 1,585
  • 3
  • 23
  • 34
-1
votes
2 answers

jQuery is not showing results

I need to make a jQuery to alert "are you sure you want to delete" when user click on delete. I've been trying a LOT but didn't find any solution. This is my deletemovie.php
ouzoumzak
  • 95
  • 1
  • 7
-2
votes
2 answers

Change default key action JavaScript

Possible Duplicate: How do I replace a keystroke with jQuery? Is there a way where I can change the default character of a key pressed in JavaScript. Like if somebody presses the "E" Button, it will print out a p instead, and this is live, so…
comu
  • 921
  • 1
  • 11
  • 29
-2
votes
2 answers

I want to stop my website from refreshing

I know i can do it with preventDefault, but i don't know where to set the preventDefault on the code... let navbar = document.querySelector(".navbar"); document.querySelector("#menu-btn").onclick = () => { …
-2
votes
1 answer

TypeError: Cannot read properties of undefined (reading 'preventDefault!!')

I keep getting the above below when I run this code I don't see anything wrong with it and I don't know why its returning the above error. it use to work before, but after coming back to it today, it gave me this error. Is there an issue with…
joe
  • 7
  • 4
-2
votes
2 answers

submit the form but page does not reload. preventDefault() not working

When I use form and try to submit, it reload the page.But my requirement is submit the form but not reload the page and send the data mention this action url. I know this duplicate Question Form
Ng Sharma
  • 2,072
  • 8
  • 27
  • 49
-2
votes
4 answers

HTML textboxes are not working

I want to redirect from current to nextpage on F1 button click. The page redirects properly, but the textboxes of the current page are not working. $(document).ready(function () { $("body").keydown(function (e) { e.preventDefault(); …
CodingFriend
  • 149
  • 1
  • 12
-2
votes
1 answer

e.preventDefault jquery not working with multiple forms and buttons

I have a problem with a JS script I'm working with : I have a page that handles various operations using AJAX, multiple forms with different IDs are inside the page and in my script I use e.preventDefault at the beginning of ever button's on submit…
K3nzie
  • 445
  • 1
  • 7
  • 20
-2
votes
1 answer

Prevent Default is not working fine

I'm trying block the event of a link, to don't add a product in a addToCart Button but is not working fine, the link is enabled yet, have idea what's wrong? Thanksss!!! $(document).ready(function(){ function buyButtonVerify() { …
Anna A.
  • 65
  • 1
  • 9
-2
votes
1 answer

Calling preventDefault on DOM element

I am currently in the process of creating an MVC4 web application, and I seem to have run into a weird issue. I have created a unordered list with some list items in it, and their respective anchor tags, in which I am going to be able to click, that…
OhTehNoes
  • 15
  • 1
  • 1
  • 4
-2
votes
1 answer

Return false on click event not working

Any idea why this code is not working? I've spend one hour searching and testing for something that was supposed to be ridicule simple! I have tried with return false and other solutions suggested in other answers but the page still jumps to the top…
drivebass
  • 137
  • 1
  • 11
-3
votes
1 answer

should I use preventDefualt() or stopPropagation() in this jquery and how?

var flip1 = 0; $( ".car-row" ).click(function() { $( ".car-types" ).toggle( ); }); When div class ".car-row" is clicked, its subdiv '.cartypes' is toggled. $('input[name=allcheck-cars]').click(function() { …
-3
votes
1 answer

What is the use of "preventDefault" in a click event?

Could you please help me in understanding what the following code does: var FluidNav = { init: function() { $("a[href*=#]").click(function(e) { e.preventDefault(); if($(this).attr("href").split("#")[1]) { …
user1157404
  • 91
  • 2
  • 11
-4
votes
1 answer

Perform AJAX request before continuing with default action

I have a basic AJAX request like so: $.ajax({ url: 'check_password.php', type: 'post', data: 'password='+password, dataType: 'json', success: function(json) { if (json['success']) { …
Peter Stuart
  • 2,362
  • 7
  • 42
  • 73
1 2 3
63
64