Shaun Mccran

My digital playground

23
D
E
C
2010

Using JQuery to disable all form fields

Whilst writing a new timesheet application I added a function to 'lock' an entire dataset, IE stop a user from editing the form on the page.

I'd spent a lot of time layout the timesheet page, designing the form, and help text etc. I didn't really want to destroy the visuals if a record was locked, I wanted it just the same, but 'non-active'.

This is where JQuery is simply awesome. Understanding 'selectors' and the power they can give you, with only very simple construction is key.

In this example imagine a page that has a div within it, the div has a id of 'divLabel'. Within that div there is a form. The code below will disable all the input elements within that div. Every single one of them. In one line of code. How cool is that.

view plain print about
1<s/cript type="text/javascript">
2    $(document).ready(function(){
3        $('#divLabel :input').attr('disabled', true);
4    });
5    // end
6</script>

What its actually doing is adding the disabled attribute to each input, then setting the value to 'true'.

Get familiar with how JQuery selectors work, the docs are here: http://api.jquery.com/category/selectors/

TweetBacks
Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
Doug Estep's Gravatar I created a widget that can completely disable or present a read-only view of the content on your page. It disables all buttons, anchors, removes all click events, etc., and can re-enable them all back again. It even supports all jQuery UI widgets as well. I created it for an application I wrote at work. You're free to use it.

Check it out at ( http://www.dougestep.com/dme/jquery-disabler-widge... ).
# Posted By Doug Estep | 17/11/2012 07:15
Arnita's Gravatar Thanks for the script i would really use it for my projects, and i am amazed to know that using J query we can disable all fields. Would like to make a try with the script and let you know the results. Thank you.
# Posted By Arnita | 25/04/2015 00:31
breitling replica's Gravatar However, the acceptable account is that a Breitling replica watchis about as acceptable as an aboriginal one. A replica watch is an exact archetype of an aboriginal alarm but it comes at a far abundant beneath price. While affairs a replica is a abundant accepted alternative, a lot of http://www.turkishpizza.co.uk humans cannot acquaint the aberration amid a replica watch and a affected watch. One way that you can acquaint the aberration amid the two is by blockage their pricing. Ideally, no 18-carat Breitling replica watchwill advertise atjust a few dollars but we now accept affected Breitling replica watchesthat advertise at beneath than $50. You should absolutely beware of low priced watches back bargain can sometimes become actual expensive.If you wish to get the best Breitling replica watches you charge to attending for the a lot of trusted watch dealers in town. Abounding of http://www.brearcadiacove.com them accept websites area you can analysis for accurate advice afore authoritative your final accommodation to buy from them. You should not alternate to analysis the reviews that accept been accounting by accomplished audience of accurate watch dealers afore affairs from them. Such reviews accommodate basic advice that touches on the candor of a watch dealer, like whether he sells affected watches or aboriginal ones. The appraisement should aswell be checked. If you are affairs a Breitling replica watchonline, accomplish abiding thatyou accept taken your time afore authoritative the accommodation on area you will buy it. Such above-mentioned blockage can in fact save you the affliction of spending your hard-earned banknote to buy a affected watch.The Omega replica archive incorporates nicely-known Omega collections, like Omega SpeedMaster chronographs, Omega SeaMaster sporty-styled timepieces, and around-the-clock Omega Constellation watches. Omega replica watches are on the http://www.teleman.org account of awful accepted timekeepers acclaimed because of to the celebrated Swiss cast title, boxy top superior and adorable style. Omega replica watches are primarily based on the abstruse achievements of the accurate watches.
# Posted By breitling replica | 08/08/2015 00:42
Derek's Gravatar it's much faster to use

$('#divLabel").find(":input').attr('disabled', true);

and dougs plugin can now be found here
https://github.com/dgestep/jquery-disabler
# Posted By Derek | 14/08/2015 09:17
mcomea's Gravatar So many students are happy to read the steps from this http://www.bigbangdissertation.com/ website. The info is architectonic robust, elegant web solutions for our students. So, we are really happy for using the information.
# Posted By mcomea | 05/09/2015 21:33
Paul's Gravatar I think you have shared an easy way to disable all form fields using JQuery. I have searched a lot to do this process, but I couldn’t do it successfully. Now I think I got the proper way to complete that process. http://www.qspray.com
# Posted By Paul | 08/09/2015 21:13
cocowei's Gravatar They are ALWAYS covering and arresting with the chat "Coach". The alone way a absolute authentic
<a href="http://www.garaventa.co.uk">replica watches</a> would appear with a metal hangtag is if it was a bound edition. The metal hangtag would consistently be accompanied by one or two covering hangtags, or <a href="http://www.interface-online.co.uk">http://...; clear studded. If you see a purse with a metal hangtag alone (often gold-colored), it is fake, or at the actual atomic its authenticity should be questioned!The easiest way to acquaint whether a is affected or absolute is by <a href="http://www.visitdevonandcornwall.co.uk">br... replica</a> the central lining of the purse. For absolute purses, it will be a solid-color glassy material. There are exceptions to this aphorism in the Legacy band of <a href="http://www.garaventa.co.uk">louis vuitton replica</a> purses, but back this is a basal adviser I am not touching on that. Affected purses may be <a href="http://www.drhaushka.co.uk">omega replica</a> lined with solid-colored cottony (very rarely, alone high-quality knock-offs will accept this), or abundant added generally with the "signature C" lining apparent in the account below.
<br><br>
<br><br>
# Posted By cocowei | 16/09/2015 01:07
Facelift Surgery's Gravatar I'd spent a lot of time layout the timesheet page, designing the form, and help text etc. I didn't really want to destroy the visuals if a record was locked, I wanted it just the same, but 'non-active'.
# Posted By Facelift Surgery | 03/10/2015 07:04
Construction's Gravatar I think you have shared an easy way to disable all form fields using JQuery. I have searched a lot to do this process, but I couldn’t do it successfully. Now I think I got the proper way to complete that process
# Posted By Construction | 11/10/2015 00:43
will the economic slump kill solar power's Gravatar I think you have shared an easy way to disable all form fields using JQuery. I have searched a lot to do this process, but I couldn’t do it successfully. Now I think I got the proper way to complete that process.
# Posted By will the economic slump kill solar power | 11/10/2015 03:20
online reputation's Gravatar This is where JQuery is simply awesome. Understanding 'selectors' and the power they can give you, with only very simple construction is key.
# Posted By online reputation | 12/10/2015 02:33
seo's Gravatar It a great idea to purchase travel cover before you begin any holiday Although your blueprints are rather safe just like driving while in the countryside plus picnicking, you require travel insurance cover.
# Posted By seo | 12/10/2015 04:05
advantage flea treatment for cats's Gravatar As always if you have any feedback or questions feel free to drop them in the comments below or contact me privately on my contact page. Thanks for reading!
# Posted By advantage flea treatment for cats | 13/10/2015 23:45
New Shuffle Dance's Gravatar This specific great site formulated almost everything Used to do to obtain which experts claim make an appearance almost nothing.
# Posted By New Shuffle Dance | 15/10/2015 23:17
send fax from gmail free's Gravatar They are members of the North division of the National Football Conference in the National Football League.
# Posted By send fax from gmail free | 15/10/2015 23:58
kovan treasure condo's Gravatar all form fields using JQuery. I have searched a lot to do this process, but I couldn’t do it successfully. Now I think I got the proper way to complete that process
# Posted By kovan treasure condo | 16/10/2015 04:36
Watch Movies Online's Gravatar First You got a great blog .I will be interested in more similar topics. i see you got really very useful topics , i will be always checking your blog thanks.
# Posted By Watch Movies Online | 16/10/2015 22:27
james samuel 5k daily profit club review's Gravatar I feel really happy to have seen your webpage and look forward to so many more entertaining times reading here. Thanks once more for all the details. halo 5 hack
# Posted By james samuel 5k daily profit club review | 18/10/2015 23:02
majigan's Gravatar k forward to so many more entertaining times reading here. Thanks once more for all the details. halo 5 hack
# Posted By majigan | 19/10/2015 03:10
Putrraanto's Gravatar Thanks for sharing. Really useful. I've tried $(#form-id input) but wrapping the form in a div as you've suggested is better I guess ? Now, I have a problem: I use the same form for viewing (disabled/readonly) and editing. When in "edit mode" I've enabled the input elements, set disabled to false. After keying in the new value, upon submitting the form, the value didn't change. Fx: input initial value = "ABC", and after changing to "ABCDEF", the value passed to server is till "ABC". What could be the problem ? Thank you.
# Posted By Putrraanto | 20/10/2015 23:50
Yoga Exercise's Gravatar I have searched a lot to do this process, but I couldn’t do it successfully. Now I think I got the proper way to complete that process
# Posted By Yoga Exercise | 21/10/2015 01:48
free mp3 downloads's Gravatar My wife and i was ready for this type of several facts on an prolonged time period. Appreciate it along with enjoy.
# Posted By free mp3 downloads | 21/10/2015 04:44
how to get out of jail's Gravatar I would like to apprentice at the same time as you amend your web site, how could i subscribe for a blog site Trade in Games.
# Posted By how to get out of jail | 22/10/2015 07:07
buy real active instagram followers's Gravatar Oh my god, thank you so much you just made my day. Not only you take us by the hand, but you also deliver everything we need to know about this in a smart way. The way you write is so clear, I will definitely keep following your guidance as you inspired me allot!.
like for instagram
http://socialgrand.com/buy-instagram-likes/
# Posted By buy real active instagram followers | 24/10/2015 23:00
dow jones focus group's Gravatar I think you have shared an easy way to disable all form fields using JQuery. I have searched a lot to do this process, but I couldn’t do it successfully. Now I think I got the proper way to complete that process.
# Posted By dow jones focus group | 25/10/2015 23:20
Trust Flow Backlinks service's Gravatar I am also visiting this web
page daily, this website is in fact good and the people are
actually sharing good thoughts.
# Posted By Trust Flow Backlinks service | 27/10/2015 00:19
Dean Schewards's Gravatar You may want to disable all form fields when the user has loaded invalid value.
I have implemented it on my site:
http://www.therowingmachinedoctor.com/
http://www.therowingmachinedoctor.com/the-concept-2-rower/
# Posted By Dean Schewards | 30/10/2015 09:41
What Men Secretly Want's Gravatar There is obviously a lot to know about this. I think you made some good points in Features also.
# Posted By What Men Secretly Want | 03/11/2015 07:12
What Men Secretly Want's Gravatar I would like to apprentice at the same time as you amend your web site..
# Posted By What Men Secretly Want | 03/11/2015 07:18
Build My List 2.0 Jimmy Kim's Gravatar designing the form, and help text etc. I didn't really want to destroy the visuals if a record was locked, I wanted it just the same, but 'non-active'.
# Posted By Build My List 2.0 Jimmy Kim | 06/11/2015 21:55
ALISTPARTNERS's Gravatar rojects, and i am amazed to know that using J query we can disable all fields. Would like to make a try with the script and let you know the results. Thank you.
# Posted By ALISTPARTNERS | 08/11/2015 03:34
the salvation diet's Gravatar I've tried $(#form-id input) but wrapping the form in a div as you've suggested is better I guess ? Now, I have a problem: I use the same form for viewing (
# Posted By the salvation diet | 08/11/2015 04:18
build my list's Gravatar i would really use it for my projects, and i am amazed to know that using J query we can disable all fields. Would like to make a try with the script and let you know the results.
# Posted By build my list | 08/11/2015 06:24
jaipur to delhi cab's Gravatar Well… round about every blog posts online don’t have much originality as I found on yours..
# Posted By jaipur to delhi cab | 10/11/2015 01:29
fatdiminishersystemreview.org's Gravatar i am amazed to know that using J query we can disable all fields. Would like to make a try with the script and let you know the results.
# Posted By fatdiminishersystemreview.org | 12/11/2015 03:47
go here's Gravatar I feel really happy to have seen your webpage and look forward to so many more entertaining times reading here
# Posted By go here | 12/11/2015 05:21
Emergency Plumbing's Gravatar It a great idea to purchase travel cover before you begin any holiday Although your blueprints are rather safe just like driving while in the countryside plus picnicking,
# Posted By Emergency Plumbing | 12/11/2015 06:30
How to apply forinsurance's Gravatar I didn't really want to destroy the visuals if a record was locked, I wanted it just the same, but 'non-active'.
# Posted By How to apply forinsurance | 13/11/2015 23:37
type my essay's Gravatar Now, I have a problem: I use the same form for viewing (disabled/readonly) and editing. When in "edit mode" I've enabled the input elements, set disabled to false. After keying in the new value, upon submitting the form
# Posted By type my essay | 14/11/2015 03:17
free essay grader's Gravatar When in "edit mode" I've enabled the input elements, set disabled to false. After keying in the new value, upon submitting the form
# Posted By free essay grader | 14/11/2015 21:50
movers in baton rouge's Gravatar I use the same form for viewing (disabled/readonly) and editing. When in "edit mode" I've enabled the input elements, set disabled to false. After keying in the new value, upon submitting the form
# Posted By movers in baton rouge | 14/11/2015 23:50
movers in baton rouge's Gravatar While affairs a replica is a abundant accepted alternative, a lot of http://www.turkishpizza.co.uk humans cannot acquaint the aberration amid a replica watc
# Posted By movers in baton rouge | 15/11/2015 00:10
Blog comments's Gravatar I feel really happy to have seen your webpage and look forward to so many more entertaining times reading
# Posted By Blog comments | 15/11/2015 01:12
tx movers's Gravatar You have provided great information in your post and some things I have not seen in other content
# Posted By tx movers | 15/11/2015 02:20
austin dental's Gravatar I have searched a lot to do this process, but I couldn’t do it successfully. Now I think I got the proper way to complete that process. .
# Posted By austin dental | 15/11/2015 03:29
best essays for sale's Gravatar i am amazed to know that using J query we can disable all fields. Would like to make a try with the script and let you know the results.
# Posted By best essays for sale | 15/11/2015 21:57
automuszakivizsgaztatas's Gravatar but I couldn’t do it successfully. Now I think I got the proper way to complete that process. .xnw
# Posted By automuszakivizsgaztatas | 16/11/2015 04:42
mattress/tuft-and-needle-10-inch-mattress-review/'s Gravatar In case doable, when you get know-how, is it possible to thoughts modernizin.
Risperdal Lawyer's Gravatar Great article Lot's of information to Read...Great Man Keep Posting and update to People..Thanks
# Posted By Risperdal Lawyer | 21/11/2015 01:51
the diabetes 60 system reviews's Gravatar Great article Lot's of information to Read...Great Man Keep Posting and update to People..Thanks
# Posted By the diabetes 60 system reviews | 21/11/2015 02:18
blc law center's Gravatar The girls can select any bin they want to wear to school BUT the clothes MUST come out of one of the bins. This gives them some choices.
# Posted By blc law center | 21/11/2015 03:41
the instant switch scam's Gravatar he girls can select any bin they want to wear to school BUT the clothes MUST come out of one of the bins. This gives them some choices.
# Posted By the instant switch scam | 21/11/2015 04:43
Quality Plumbing's Gravatar I didn't really want to destroy the visuals if a record was locked, I wanted it just the same, but 'non-active'.
# Posted By Quality Plumbing | 22/11/2015 00:55
Anniversary Ideas's Gravatar Fine with your permission allow me to grab your RSS feed to keep updated with forthcoming post.
# Posted By Anniversary Ideas | 24/11/2015 21:51
the venus factor review youtube's Gravatar Fine with your permission allow me to grab your RSS feed to keep updated with forthcoming post.
# Posted By the venus factor review youtube | 25/11/2015 00:33
learn to play piano's Gravatar Fine with your permission allow me to grab your RSS feed to keep updated with forthcoming post.
# Posted By learn to play piano | 25/11/2015 03:54
Aluminium Guttering's Gravatar Hello there, You’ve performed an excellent job. I’ll certainly dig it and for my part recommend to my friends. I’m confident they’ll be benefited from this website
# Posted By Aluminium Guttering | 25/11/2015 07:16
jaipur to delhi taxi's Gravatar I feel really happy to have seen your webpage and look forward to so many more entertaining times reading here. Thanks once more for all the details.
# Posted By jaipur to delhi taxi | 05/12/2015 03:38
important link's Gravatar I feel really happy to have seen your webpage and look forward to so many more entertaining times reading here. Thanks once more for all the details.
# Posted By important link | 13/12/2015 21:42
gain more instagram followers's Gravatar I feel really happy to have seen your webpage and look forward to so many more entertaining times reading here. Thanks once more for all the details. halo 5 hack
# Posted By gain more instagram followers | 18/12/2015 22:10
cccam server's Gravatar I want you to thank for your time of this wonderful read!!! I definitely enjoy every little bit of it and I have you bookmarked to check out new stuff of your blog a must read blog....
# Posted By cccam server | 18/12/2015 23:46
Xarelto Deaths - The Dangers of Xarelto's Gravatar I'm able to bookmark your site and show the kids check out up here generally. I m fairly positive there likely to be informed a great deal of new stuff here than anyone.
# Posted By Xarelto Deaths - The Dangers of Xarelto | 19/12/2015 01:57
Online Courses's Gravatar Great Post This is also a very good post which I really enjoyed reading. It is not everyday that I have the possibility to see something like this..Thank You!
# Posted By Online Courses | 21/12/2015 02:08
cccam server's Gravatar There’s a moment in the movie Manhattan when Woody Allen’s character, Isaac Davis, is arguing with his TV show co-workers about a bit that isn’t working...
# Posted By cccam server | 22/12/2015 00:24
cheap research paper writing's Gravatar Firstly create a CurrencyFormatter object, and specify the currency symbol, and any other formatting parameters that you require.
# Posted By cheap research paper writing | 26/12/2015 02:03
check this out's Gravatar Good to become visiting your weblog again, it has been months for me. Nicely this article that i've been waited for so long.
# Posted By check this out | 28/12/2015 01:30
check this out's Gravatar Your site and show the kids check out up here generally. I m fairly positive there likely to be informed a great deal of new stuff here than anyone.
# Posted By check this out | 29/12/2015 00:16
buy followers on instagram cheap's Gravatar I m fairly positive there likely to be informed a great deal of new stuff here than anyone.
# Posted By buy followers on instagram cheap | 30/12/2015 23:17
buy mixcloud plays's Gravatar I m fairly positive there likely to be informed a great deal of new stuff here than anyone.
# Posted By buy mixcloud plays | 31/12/2015 07:03
pure garcinia cambogia's Gravatar I m fairly positive there likely to be informed a great deal of new stuff here than anyone.
# Posted By pure garcinia cambogia | 05/01/2016 23:13
amazon top products's Gravatar I have feel that this blog is really have all those quality that qualify a blog to be a one.I wanted to leave a little comment to support you and wish you a good continuation.
# Posted By amazon top products | 09/01/2016 00:54
DUI Lawyer's Gravatar I have feel that this blog is really have all those quality that qualify a blog to be a one.I wanted to leave a little comment to support you and wish you a good continuation.
# Posted By DUI Lawyer | 19/01/2016 23:42
Back to top