Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

JQuery - disable links if any form inputs change.

Posted on 2010-09-24
4
Medium Priority
?
522 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 40

Accepted Solution

by:
Gurvinder Pal Singh earned 1000 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 1000 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

Technology Partners: 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

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article discusses how to create an extensible mechanism for linked drop downs.
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)
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…

604 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