.aspx.vb中的JS客户端警报声明

时间:2022-11-07 23:54:12

I am fairly new to hard coding & VS. I have successfully created a couple applications using .aspx so I am beginning to understand a little more.

我是硬编码和VS的新手。我已经使用.aspx成功创建了几个应用程序,所以我开始了解更多。

I have a form (.aspx) which has a yes/no dropdown box, if the user selects yes, it's necessary to populate the following empty text box (TextBox13 "Reason/Comment"). And I need to add a CLIENT side alert message (using JS, I have found to be the answer) to which I have tried using samples I have found. Problem is, none of the examples are for exactly what I need.

我有一个表单(.aspx),它有一个是/否下拉框,如果用户选择是,则需要填充以下空文本框(TextBox13“Reason / Comment”)。我需要添加一个CLIENT端警报消息(使用JS,我发现是答案)我尝试使用我找到的样本。问题是,没有一个例子是我所需要的。

So far, I did create a .js page:

到目前为止,我确实创建了一个.js页面:

$('#MP_Form').submit(function(e) {
  if(!$.trim($(this).find('TextBox13'="text"').val()).length){
      e.preventDefault();
     alert('If critical, you must provide a reason/comment.');
    }
});
}

I added the in my master page, and understand I need a statement in my aspx.vb page with a function. I think the onSubmit is what I want but not sure how to write the if, then statement. Can someone please help me out?
Thanks! Kathy

我在我的母版页中添加了,并且理解我需要在我的aspx.vb页面中使用函数声明。我认为onSubmit是我想要的,但不知道如何编写if,then语句。有人可以帮帮我吗?谢谢!凯西

1 个解决方案

#1


0  

Have a look at the following jsfiddle. There's an input and a button. To get the text in the input I use the following:
$('#inputId').val();
In my case inputId is comment, so in my case it's $('#comment').val();

看看下面的jsfiddle。有一个输入和一个按钮。要获取输入中的文本,我使用以下内容:$('#inputId')。val();在我的情况下,inputId是注释,所以在我的情况下它是$('#comment')。val();

#1


0  

Have a look at the following jsfiddle. There's an input and a button. To get the text in the input I use the following:
$('#inputId').val();
In my case inputId is comment, so in my case it's $('#comment').val();

看看下面的jsfiddle。有一个输入和一个按钮。要获取输入中的文本,我使用以下内容:$('#inputId')。val();在我的情况下,inputId是注释,所以在我的情况下它是$('#comment')。val();