日期:2014-05-18 浏览次数:20440 次
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <script src="http://www.veryhuo.com/uploads/common/js/jquery-1.4.2.min.js" type="text/javascript"></script> <script type="text/javascript"> $(function () { $("input[type=radio]").click(function (e) { var flag = $("input[name='test']:checked").val(); if (flag == 1) { alert("A"); //验证文本框A } else { //验证文本框B alert("B"); } }); }); </script> </head> <body> <input type="radio" value="1" name="test"/><label>A</label> <input type="radio" value="2" name="test"/><label>B</label> </body> </html>
------解决方案--------------------
$("input[type=radio]:checked").each(function () { if ($(this).length == 1) { var text = $(this).val(); if (text == "RadioButton1") { alert("验证第一个文本框"); } } });