0

我创建了 joomla 模块并添加了日历表单字段。

<field name="date" type="calendar" default="2010-01-30" format="%Y-%m-%d" label="Enter date" description="" class="date_field" />

用户使用日历图标输入日期时一切正常,但如果用户写入任何其他信息,则在保存模块设置后一切都会崩溃。

我的想法是让输入字段只读,但如果我使用 readonly="true",那么 callendar 图标就会消失。

4

2 回答 2

1

I think you would need to do some mootools or jquery-magick (depending on your joomla-version) to disable manual input in the textbox. Using jquery you could do something like:

jQuery('.calendar-textfield-class').focusin(function (event){
event.preventDefault(); 
jQuery(this).next('button').focus().click(); 
});  

This should trigger the calendar select popup if the user tries to input the date manually.

Regards Jonas

于 2014-04-05T22:03:39.870 回答
1
jQuery(document).ready(function(){
    jQuery(document).on('keydown', '#jform_scheduled_time', function(event) {
       return false;
    });
});

Try this and user will not able to write anything in calendar box and for opening calendar pop up on click anywhere do this-

jQuery(document).on('focusin', '#jform_scheduled_time', function(event) {
           event.preventDefault();
           jQuery(this).parent().siblings(':eq(0)').show();
    });
于 2018-08-16T10:39:09.527 回答