Remove Button for javascript

Asked

Viewed 261 times

2

How to remove or disable the (cancel) button from the javascript prompt function?

2 answers

2

Good afternoon friends!

It is not yet possible to change the dialogs generated through the window follow HTML spec

Trying to solve your problem you can use some lib to generate dialogs through the DOM.

1


Currently it is not possible to disable the button, but a solution could be to force the person to write opening another prompt when the initial is canceled:

function noRefuse() {
  do {
    x = prompt("Responda minha pergunta!")
  } while(!x)
}

var botao = document.getElementById('prompt')

botao.addEventListener('click', noRefuse);
<input type='button' id='prompt' value='Prompt'>

In that case, if the person cancels or declines, it will open another prompt (just like if responding blank).

Browser other questions tagged

You are not signed in. Login or sign up in order to post.