[Javascript]如果选中复选框C_1,则需要字段? [英] [Javascript] If checkbox C_1 is selected fields required?

查看:58
本文介绍了[Javascript]如果选中复选框C_1,则需要字段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好。


我有这个简单的表格。


我需要选中复选框C_1:


1)字段名称=" n_1"是必填项并且仅接受数字;

2)字段名称=" n_2"是必填项并且仅接受数字;


如果选中复选框C_2,我需要:


3)字段名称=" n_3"是必填项并且仅接受数字;

4)字段名称=" n_4"是必需的,只接受数字;


如果没有选中复选框,则不需要任何字段。


你能帮助我吗?

Hi all.

I have this simple form.

I need if checkbox C_1 is selected:

1) field name="n_1" is required and accept only numbers;
2) field name="n_2" is required and accept only numbers;

I need if checkbox C_2 is selected:

3) field name="n_3" is required and accept only numbers;
4) field name="n_4" is required and accept only numbers;

If checkbox not selected no required fields.

Can you help me?

展开 | 选择 | Wrap | 行号

推荐答案

你可以(使用两个表格)查询复选框{checkbox_element} .checked然后选择表单/表单元素来检查有效输入。


问候


PS:你可以省略href属性,如果你设计那些使用css的锚点
you could (use two forms,) query the checkboxes with {checkbox_element}.checked and then select the forms/form elements to check for valid input.

regards

PS: you can omit the href attribute, if you style those anchors with css



你可以(使用两个表格)查询{checkbox_element} .checked的复选框,然后选择表格/表格元素来检查有效输入。


问候


PS:你可以省略href属性,如果你用css
设置锚点
you could (use two forms,) query the checkboxes with {checkbox_element}.checked and then select the forms/form elements to check for valid input.

regards

PS: you can omit the href attribute, if you style those anchors with css



mmm对不起但是我不明白...... 。

mmm sorry but I dont understand....



mmm对不起但我不明白....
mmm sorry but I dont understand....



你不懂什么?复选框的东西?每个checkbox元素都有一个名为''checked''的属性。您可以测试此属性是真还是假,具体取决于您可以进行验证。


问候

what don''t you understand? the checkbox thing? well every checkbox element has a property called ''checked''. you can test if this property is true or false and depending on that you can do the validation.

regards


这篇关于[Javascript]如果选中复选框C_1,则需要字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆