简体   繁体   English

.aspx.vb中客户端警报的JS语句

[英]JS Statement for Client Side Alert in .aspx.vb

I am fairly new to hard coding & VS. 我对硬编码和VS非常陌生。 I have successfully created a couple applications using .aspx so I am beginning to understand a little more. 我已经成功地使用.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"). 我有一个窗体(.aspx),其中有一个“是/否”下拉框,如果用户选择“是”,则必须填充以下空文本框(TextBox13“原因/注释”)。 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. 我需要添加一个CLIENT侧警告消息(使用JS,我找到了答案),我已经使用发现的示例对其进行了尝试。 Problem is, none of the examples are for exactly what I need. 问题是,这些示例都不是我所需要的。

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. 我在主页面中添加了,并了解到我需要在aspx.vb页面中使用函数声明。 I think the onSubmit is what I want but not sure how to write the if, then statement. 我认为onSubmit是我想要的,但不确定如何编写if,then语句。 Can someone please help me out? 有人可以帮我吗?
Thanks! 谢谢! Kathy 凯西

Have a look at the following jsfiddle . 看看下面的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(); 在我的情况下,inputId是comment,所以在我的情况下,它是$('#comment').val();

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

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