简体   繁体   English

使用JQuery,C#将单选按钮上的标签文本的提交值保留在单击状态

[英]keep submitted values of a label text on radio button click with JQuery, C#

I Have the JQuery code following under to change text label values in a formulary. 我下面有JQuery代码来更改配方中的文本标签值。 But on submit them(if have an invalid filled field), the text label values returns of the original value. 但是在提交它们时(如果具有无效的填充字段),文本标签值将返回原始值。 How can i keep these values for not fill the fields again? 如何保留这些值以免再次填写字段?

<script type="text/javascript">

    $(document).ready(function () {
        $('input:radio').change(function () {
            var rbvalue = $('input:radio:checked').val();
            if (rbvalue === "D") {
                $('#idCard').html('IC:');
                $('#userName').html('User Name: ');
                $('#completeName').html('Complete Name: ');
                $('#userAdress').html('User Adress: ');
            }
            else if (rbvalue === "B") {
                $('#publicId').html('Public Identificator: ');
                $('#publicName').html('Public Name: ');
                $('#publicCompleteName').html('Public Complete Name: ');
                $('#publicAdress').html('Public Adress: ');
            }

        });
    }); 
</script>

You can: 您可以:

  1. Write a server-side routine that changes the label text so the page will render correctly after postback. 编写一个服务器端例程,以更改标签文本,以便页面在回发后将正确呈现。
  2. Store the client-side labels in a hidden field before form submission and then use JavaScript to restore the labels after postback. 在提交表单之前,将客户端标签存储在隐藏字段中,然后在回发后使用JavaScript还原标签。
  3. Use an AJAX call to check values prior to actual form submission and prevent the form from being submitted if the values are incorrect. 使用AJAX调用在实际提交表单之前检查值,如果值不正确,则阻止提交表单。
  4. Do entirely client-side validation and prevent the form from being submitted if the values are incorrect. 完全进行客户端验证,如果值不正确,则阻止提交表单。

Or any combination of the above. 或以上的任何组合。

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

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