需要Java脚本验证 [英] Java Script Validation Required

查看:54
本文介绍了需要Java脚本验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

伙计们,



我需要你对以下情况的善意指导。



我有我的表单中包含1个文本框和2个复选框的部分。

我想应用验证,一次只有3个应该启用,在取消选择后,控制权可以转移到另一个。 ..



即如果我们在复选框中写了一些东西,那么两个复选框都无法检查,如果我们选择任何一个复选框而不是文本框,第二个复选框不能填写。



我已在复选框上应用验证但无法完全应用于文本框。





问题是,当我在文本框中写一些东西时,两个文本框都被禁用但是即使我清空文本框也无法再次启用。



请在这方面帮助我。

Hi fellows,

I need your kind guidance regarding the following scenarios.

I have a section in my form which contains 1 textbox and 2 checkboxes.
I want to apply validation, that at one time only of the 3 should only be enabled and after unselecting them control could be transfered to another...

i.e. if we write some thing in checkbox then both checkboxes cant be checked and if we select any one checkbox than textbox and 2nd checkbox cant be filled.

I have applied validation on checkboxes but unable to apply on textbox completely.


problem is that when i write some thing in textbox than both textboxes got disabled but than can not be enabled again even if i do empty the textbox.

Kindly do help me in this regards.

推荐答案

你好,



我带了一个小型原型机。请让我知道这对你有没有用。
Hello,

I have come with a small prototype. Let me know if it works for you.
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script type="text/javascript">
function enforce(ctrl) {
    if (ctrl.id === "txtName") {


' < span class =code-string>#chkOne')。prop( disabled,ctrl.value.length> 1 );
('#chkOne').prop("disabled", ctrl.value.length > 1);


' #chkTwo')。prop( disabled,ctrl.value .length> 1 );
}
else if (ctrl.id === chkOne){
('#chkTwo').prop("disabled", ctrl.value.length > 1); } else if (ctrl.id === "chkOne") {


这篇关于需要Java脚本验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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