Help for JS to disable dropdown and date fields
Help for JS to disable dropdown and date fields
I have samples of JS code for regular inputs but they are not working for dropdown and date type fields. Can someone assist how to disable those on the forms so users cannot choose a dropdown value or a date? Thank you.
Re: Help for JS to disable dropdown and date fields
Using Rukovoditel since 2022 --- v3.4 (with extension) in French on PHP 8.2
I keep the French translation up to date
I'm trying to help you (+10 years experience in html, css, php, sql, JS/jquery, python)
I keep the French translation up to date
I'm trying to help you (+10 years experience in html, css, php, sql, JS/jquery, python)
Re: Help for JS to disable dropdown and date fields
Thank you. I am checking those time to time and there are very useful samples of code there. However, I am not able to locate any sample that will specifically disable DROPDOWN and DATE type of fields. Sorry if they are there and I missed them. Can you please check and assist? Thank you.
Re: Help for JS to disable dropdown and date fields
Sure maybe I didn’t write all my codes.
Disabled what do you mean ? Hidden or visible with the value but can’t change ?
Can you describe what do you want to see ?
And maybe create a demo as easy way to show you
https://www.rukovoditel.net/demo.php
Disabled what do you mean ? Hidden or visible with the value but can’t change ?
Can you describe what do you want to see ?
And maybe create a demo as easy way to show you
https://www.rukovoditel.net/demo.php
Using Rukovoditel since 2022 --- v3.4 (with extension) in French on PHP 8.2
I keep the French translation up to date
I'm trying to help you (+10 years experience in html, css, php, sql, JS/jquery, python)
I keep the French translation up to date
I'm trying to help you (+10 years experience in html, css, php, sql, JS/jquery, python)
Re: Help for JS to disable dropdown and date fields
Hi, visible with the value on the form but can’t change = disabled. Below or similar ones do work on text inputs but NOT on dropdown and date fields. Thank you.
$('#fields_1234').prop('disabled', true);
$('#fields_1234').prop('disabled', true);
Re: Help for JS to disable dropdown and date fields
Any suggestions will be appreciated. Thank you.
-
- Posts: 651
- Joined: 30 Oct 2017, 11:24
- Name: Enis Hemedoglu
- Location: Istanbul, Turkey
- Company Name: SCORE DANISMANLIK
- Contact:
Re: Help for JS to disable dropdown and date fields
Try one of these, they should work for dropdown.
Use them on form JS section.
1.
2.
and use these on on-submit JS section.
1.
2.
You should use 1-1 or 2-2 on both JS sections.
Use them on form JS section.
1.
Code: Select all
$('#fields_XXXX').attr("disabled", true);
Code: Select all
$('#fields_XXXX_rendered_value').css('pointer-events', 'none');
1.
Code: Select all
$('#fields_XXXX').attr("disabled", false);
Code: Select all
$('#fields_XXXX_rendered_value').css('pointer-events', 'auto');
Re: Help for JS to disable dropdown and date fields
2-2 worked! Thank you very much.
Re: Help for JS to disable dropdown and date fields
I recommend to use the 1 and 1 solution,
For 2-2 :
Some browsers have maybe lack of compatibility with this function,
Also, visually I think this approach is less intuitive,
And it can be lack of accessibility for some technologies or support (because of pointers)
For 2-2 :
Some browsers have maybe lack of compatibility with this function,
Also, visually I think this approach is less intuitive,
And it can be lack of accessibility for some technologies or support (because of pointers)
Using Rukovoditel since 2022 --- v3.4 (with extension) in French on PHP 8.2
I keep the French translation up to date
I'm trying to help you (+10 years experience in html, css, php, sql, JS/jquery, python)
I keep the French translation up to date
I'm trying to help you (+10 years experience in html, css, php, sql, JS/jquery, python)
Re: Help for JS to disable dropdown and date fields
Hi, I just noticed that when you use 2-2 only, strangely when user clicks the header of the date field, he/she can alter the field. I tried using both 1-1 and 2-2 on the same JS entry and it worked perfectly fine. I do not know why, just trial and error.
Just fyi, for anyone out there who may need. Thanks again
Just fyi, for anyone out there who may need. Thanks again