Solved

JQuery - disable links if any form inputs change.

Posted on 2010-09-24
4
514 Views
Last Modified: 2012-05-10
Hi,
I am desperate for a bit of JQuery code that when a class is given to a form, if any of the inputs change without the submit being clicked, it will disable all links on the page and put an 'are you sure' message up.
I imagine that if any $('input') gets focus then it calls a function to add a class to disable links, but if $(input[type='text']) is pressed then the disable links class is removed...
0
Comment
Question by:jdav357
  • 2
4 Comments
 
LVL 40

Accepted Solution

by:
gurvinder372 earned 250 total points
ID: 33752514
try

$("input").change(function(){
  disableAllLinks();
});

http://api.jquery.com/change/

function disableAllLinks()
{
   $("a").unbind('click');
}

http://api.jquery.com/unbind/
0
 
LVL 82

Assisted Solution

by:leakim971
leakim971 earned 250 total points
ID: 33755090
You can use multiple selectors for example if you don' want to do something when textbox is clicked (input[type='text']) use the not-equal selector : http://api.jquery.com/attribute-not-equal-selector/
input[type!='text']

You can have multiple selector, for example :

$(input[type='button'],input[type!='text'])
0
 
LVL 2

Author Closing Comment

by:jdav357
ID: 33835911
Thanks
0
 
LVL 82

Expert Comment

by:leakim971
ID: 33835926
You're welcome! Thanks for the points!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question