i am trying to make,when checkbox is checked textbox should be shown but when check box is unchecked text box should be hide.This is how i implement this so far.
Examination Required:
Remarks Examination:
Sachin SinghPosted Sep 21, 2022, 6:04 AM
Yes, there was a typo
Garima BansalPosted Sep 21, 2022, 7:41 AM
there is big mistake, ID of requiredfield is in correct
$(function () {
if ($("[id*='chkexamination']").is(":checked")) {
$("[id*='chkremarks']").show();
}
ValidatorEnable($("[id*='RequiredFieldValidator4']")[0], $("[id*='chkexamination']").is(":checked")); //correct ID
ValidatorEnable($("[id*='chkremarks']")[0], $("[id*='chkexamination']").is(":checked")); //incorrect ID
})
$("[id*='chkexamination']").click(function () {
if ($(this).is(":checked")) {
$("[id*='chkremarks']").show();
ValidatorEnable($("[id*='RequiredFieldValidator4']")[0], $("[id*='chkexamination']").is(":checked")); //correct ID
ValidatorEnable($("[id*='chkremarks']")[0], $("[id*='chkexamination']").is(":checked")); //incorrect ID
}
else {
$("[id*='chkremarks']").hide();
ValidatorEnable($("[id*='RequiredFieldValidator4']")[0], $("[id*='chkexamination']").is(":checked")); //correct ID
ValidatorEnable($("[id*='chkremarks']")[0], $("[id*='chkexamination']").is(":checked")); //incorrect ID
}
}
);
Garima BansalPosted Sep 21, 2022, 6:57 AM
i have one checkbox i.e. if checkbox is checked then textbox show oherwise hiddden
and on button Save if checkbox is unchecked then required field validator must be disable
Whether Further Examination Required:
Garima BansalPosted Sep 21, 2022, 6:47 AM
i tryed and tested each one of your solution but i dont find where is the problem
Garima BansalPosted Sep 21, 2022, 5:58 AM
now, error is
id is not defined
Sachin SinghPosted Sep 21, 2022, 5:52 AM
There is no [0].is in my updated code, you copied from my earlier replies, please check the latest one. Copy from sept 21st reply
Garima BansalPosted Sep 21, 2022, 5:50 AM
getting an error in while i see in console
$(...)[0].is is not a function
Sachin SinghPosted Sep 21, 2022, 5:43 AM
@Garima, Test this
Garima BansalPosted Sep 21, 2022, 4:43 AM
Sachin Singh
by applying your updated code, now hidden textbox is not visible
Sachin SinghPosted Sep 20, 2022, 12:06 PM
Give it a try
Sachin SinghPosted Sep 20, 2022, 12:04 PM
If you will remove then it will not be a required field even when checkbox is checked. However save will start working.
Garima BansalPosted Sep 20, 2022, 11:51 AM
Whether Further Examination Required:
$(function () {
if ($([id *= 'chkexamination']).is(":checked")) {
$("[id*='chkremarks']").show();
ValidatorEnable($("[id*=chkremarks]"),
$("[id*=chkexamination]").is(":checked"));
}
})
$("[id*='chkexamination']").click(function () {
if ($(this).is(":checked")) {
$("[id*='chkremarks']").show();
}
else {
$("[id*='chkremarks']").hide();
}
ValidatorEnable($("[id*=chkremarks]"), $("[id*=chkexamination]").is(":checked"));
}
);
i use this , but not working
Garima BansalPosted Sep 20, 2022, 11:44 AM
can i remove required field validtor ?
Sachin SinghPosted Sep 20, 2022, 11:30 AM
@Garima, you need to do this to disable the validator
Garima BansalPosted Sep 20, 2022, 10:48 AM
as i use required field validator, senerio is when textbox hidden then requiredfield validator is enale
Garima BansalPosted Sep 20, 2022, 10:42 AM
Sachin Singh
there is a problem, when i dont need any data insert in textbox then its data is not saving
Sachin SinghPosted Sep 20, 2022, 5:57 AM
@Garima your answer is wrong , if in the first load your checkbox will be checked (suppose for edit) then also div will not display, until you uncheck the checkbox.
Sachin SinghPosted Sep 20, 2022, 5:55 AM
Use below code
1. For page load
2.For checkbox check
add below lines of code
Garima BansalPosted Sep 20, 2022, 5:52 AM
its done,
i use the property
Garima BansalPosted Sep 20, 2022, 5:44 AM
the way i am using its working but i want it when page open
Vishal YelvePosted Sep 20, 2022, 5:41 AM
Try this