简体   繁体   English

HTML5必填属性,是否找到了javascript,但未输入?

[英]HTML5 required attribute, javascript on required found but not entered?

Background info 背景资料

I am trying to upgrade a custom CMS to support the HTML5 validation like required. 我正在尝试升级自定义CMS以支持所需的HTML5验证。 When I have multiple languages for the same content, the form is put into tabs like (EN,ES,DE,etc). 当我针对同一内容使用多种语言时,该表格将被放入选项卡(如EN,ES,DE等)中。 When a user clicks each tab they edit the contents of that language. 用户单击每个选项卡时,他们将编辑该语言的内容。 (see image) (见图片)

Problem 问题

When a required field in ES is not filled in and the user currently has EN selected, nothing is highlighted since the ES is currently hidden. 如果未填写ES中的必填字段,并且用户当前选择了EN,则由于ES当前处于隐藏状态,因此不会突出显示任何内容。 Can I catch the html5 built in validation and use jquery to change the tab or do I need to stick with the completely jquery based validation I had before (iterating through each input with required and checking $(this).val().length) 我可以捕获内置的html5验证并使用jquery来更改选项卡,还是需要坚持以前使用的完全基于jquery的验证(通过要求的每个输入进行迭代并检查$(this).val()。length)

示例图像以显示我的意思

This is the only solution I came up with: Displaying all languages. 这是我想到的唯一解决方案:显示所有语言。

$('#btn_submit').bind('click', function() {
    $('#content input:text[required]').parent('.lang_box').show();
});

Sample 样品
http://jsfiddle.net/TkrVU/3/ http://jsfiddle.net/TkrVU/3/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM