Solved

JQuery - disable links if any form inputs change.

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
This article discusses how to create an extensible mechanism for linked drop downs.
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…

758 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now