0

I have a form (in a JSP file) with:

  • A textarea named textarea1.

  • A button type submit.

I do this:

... // My form.
String text=request.getParameter("textarea1"); 
if(text!=null){
  ... // ???? 
  ... // Code.
  ... // ????
}

I need to disable my button submit and enable it after (see the comments '????'). Another valid option for me (I think) is blocking and unblocking all my form (textarea and button). How can I do these (disable/enable the button and block/unblock the form)?

Code Lღver
  • 15,573
  • 16
  • 56
  • 75
Pep
  • 31
  • 1
  • 7
  • you need check if textarea is blank then blank then disable the submit button else enable it...is that you want?? – Pratik Apr 03 '15 at 11:34
  • @Pratik - No, my button it appears when my textarea it's no blank (it's not my problem). When I press this button, this textarea maintains your content and then I analyze the text of the textarea (in the same JSP page). Imagine that you are interested in knowing the content of the textarea ("You've written 'hello, world.' in the textarea."). So, and simplifying, I want to ''block'' the button until I see "You've written ...". When I see the message, the button should be reactivated, avoiding the double click, etc. Do you understand me? – Pep Apr 03 '15 at 17:42

2 Answers2

3

Solved: :-)

I've got this link:

In a line:

<INPUT TYPE="submit" VALUE="Run" name="1" id="Run"
style="visibility:hidden" 
onClick="this.disabled=true;this.value='Running...";this.form.submit()" 
onmouseover="window.status='INFO: Run.'" onmouseout="window.status=''">

My style is necessary (initially this button has to be hidden).

My sequence:

  1. Button initially hidden (0 characters in my textarea).

  2. I write a character in my textarea.

  3. It appears the button 'Executar' (in English, 'Run').

  4. I click 'Run'. With a single click (always)...

  5. This button (disabled) tells me 'Running...'.

  6. When the execution finishes the button 'Run' disappears, and it reappears if I want to modify the textarea (has some character).

It works with:

  • IE 6 and 9.

  • Mozilla Firefox 9.0.1 and 37.0.

  • Chrome 41.0.

Community
  • 1
  • 1
Pep
  • 31
  • 1
  • 7
0

try this you can use this code for enable and disable button call myfunction() and myfunction1() where you want to enable and disable button.

<!DOCTYPE html>
<html>
<body>

<input type="submit" id="Submit">

<div>Click the enable and disable buttom </Div>

<button onclick="myFunction()">Disable</button>
<button onclick="myFunction1()">Enable</button>

<script>
function myFunction() {
document.getElementById("Submit").disabled = true;
}
function myFunction1() {
document.getElementById("Submit").disabled = false;
}
</script>

</body>
</html>
anand kulkarni
  • 156
  • 1
  • 12