Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Creating a custom prompt with js

I’m trying to create a custom version of the prompt() function in js, that can be styled according to client specs.

However, I am not sure how to get a custom function to pause scripts until a ‘yes’ or ‘no’ is selected, and therefore how to get that function to eval to either true or false the same way a simple prompt() would.

Can anyone point me in the right direction to research?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Yeah prompt() can’t be styled, it is an in-built browser feature and has no way of pausing until clicked.

As others have said, and also what I would do, is make a modal that you can style to your desire. Then, "promisify" it (in that, create a promise and once you select something, resolve the promise), and this will basically wait until ‘yes’ or ‘no’ is clicked.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading