I have a form (in a JSP file) with:
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)?
Solved: :-)
I've got this link:
- How to disable submit button once it has been clicked?
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:
Button initially hidden (0 characters in my textarea).
I write a character in my textarea.
It appears the button 'Executar' (in English, 'Run').
I click 'Run'. With a single click (always)...
This button (disabled) tells me 'Running...'.
When the execution finishes the button 'Run' disappears, and it reappears if I want to modify the textarea (has some character).
It works with:
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>