html - how to disable jquery date picker on radio button -
I'm new to jQuery
I have two radio buttons and two text boxes, in which I Display the date using jquery.
When I click on Radio 1, then I should be able to select the date I want in both text boxes, but when I click on Radio 2, I want to select the date in Text 2 field Should not be able to. Lesson 2 field should be disabled and jquery date picker should not work.
I disabled the text2 field but the date function is still working.
-
My code goes here
& lt; Script language = 'javascript' & gt; & Lt ;! - // function setReadOnly (obj) {if (obj.value == "yes") {document.forms [0] .text2.style.backgroundColor = "#ffffff"; Document.forms [0] .text2.readOnly = 0; Document.forms [0] .text2.value = ""; } And {document.forms [0] .text2.style.backgroundColor = "#eeeeee"; Document.forms [0] .text2.readOnly = 1; Document.forms [0] .text2.value = "Not Applicable!"; Document.forms [0] .number = disbaled; }} // -> & Lt; / Script & gt; & Lt; Script & gt; $ (Document) .ready (function () {$ ("# text1") Datepicker ({showOn: 'button', button image: 'images / cal.gif', button image only: true, dateFormat: 'dd $ ("# Text2") $ ("# text2"). Datepicker ({showOn: 'button', button image: 'images / cal.gif', button image only: correct, date Format: 'dd-mm-yy', numberofmonth: 2, minadet: 1}}}) function set readonly (obje) {if (obj.value == "yes") {$ ('# text2 '). CSS ('Background Collar', '#FFFFF'); $ ('#text2') removeAttr ('Read Only'). $ ('#text2') value ('') $ ('# Text2') datepicker ('enable'). $ ('# Number') removeAttr ('disabled'). } And {$ ('# text2'). CSS ('background color', '#EEE'); $ ('#text2') attr ('Read Only', 'Read Only') $ ('# Text2') Val ('Not applicable!'); $ ('#text2') datepicker ('unable'). $ ('# Number') attr ('disabled', true). }} Edit: While the above code works just fine, as stated by Deviate, taking the full benefit of the powerful of jQuery Can be chained for FEATURES function set readonly (obje) {if (obj.value == "yes") {$ ('# text2'). CSS ('Background Callier', '#FFFFF') RemoveAttr ('readonly') .val ('') .datepicker ('enabled'); $ ('# Number') removeAttr ('disabled'). } And {$ ('# lesson 2'). CSS ('Background Color', '# eeeeee') .attr ('Read Only', 'Readable') .val ('Not Applicable!') .Date Picker ('Disabled'); $ ('# Number') attr ('disabled', true). }}
Comments
Post a Comment