C# 带Javascript的RadioButton(MVC3)

C# 带Javascript的RadioButton(MVC3),c#,javascript,asp.net-mvc-3,radio-button,maskedinput,C#,Javascript,Asp.net Mvc 3,Radio Button,Maskedinput,我正在与C#和MVC3合作 我有一个单选按钮,根据选择的选项,我需要更改文本框的掩码。 我正在为jQuery使用屏蔽输入插件 我该怎么做?我必须在控制器或.cshtml上开发它 <div class="editor-field"> @Html.LabelFor(model => model.Type) @Html.Label("Test Label") @Html.RadioButtonFor(model => mo

我正在与C#和MVC3合作

我有一个单选按钮,根据选择的选项,我需要更改文本框的掩码。 我正在为jQuery使用屏蔽输入插件

我该怎么做?我必须在控制器或.cshtml上开发它

    <div class="editor-field">
        @Html.LabelFor(model => model.Type)
        @Html.Label("Test Label")
        @Html.RadioButtonFor(model => model.RbTest, "F", true)

        @Html.Label("Test Label 2")
        @Html.RadioButtonFor(model => model.RbTest, "J")

        @Html.LabelFor(model => model.LabelBla)
        @Html.EditorFor(model => model.NeedMask)
    </div>

@LabelFor(model=>model.Type)
@Html.Label(“测试标签”)
@RadioButton(model=>model.RbTest,“F”,true)
@Html.Label(“测试标签2”)
@Html.radioButton(model=>model.RbTest,“J”)
@LabelFor(model=>model.LabelBla)
@EditorFor(model=>model.NeedMask)
如果我选择“F”(第一个单选按钮),我想要一个面具。 如果我选择“J”(第二个单选按钮),我需要另一个面具


我需要屏蔽编辑器:“NeedMask”

我知道addClass()和removeClass()有一个jquery函数。所以你可以这样做:

$(".f").click(function(){
       this.addClass("NeedMask");
    });
我实际上在atm机上工作,但这应该让你朝着正确的方向开始。我会查看jQuery文档以获得有关屏蔽的帮助(您还需要使用
$(“.J”)。removeClass(“NeedMask”)
完成

@Html.RadioButton("RbTest", "F", true, new { @onclick = "Mask1()" })
@Html.RadioButton("RbTest", "J", false, new { @onclick = "Mask2()" })

你需要一些JavaScript。是的,我试过:$(function(){$('#RbTest')。单击(function(event){Alert(“Wow!”);});但是你要么想把代码放在引用的.js文件中,要么放在标记中