Pregunta

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.

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.

So far, I did create a .js page:

$('#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

No hay solución correcta

Otros consejos

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();

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top