Solved

JQuery - disable links if any form inputs change.

Posted on 2010-09-24
4
503 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

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'…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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 code hide show and toggles. 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…

773 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