1

Is it possible to customize a javascript alert? I was wanting to make an alert for my contact form validation. Is this possible or am i just dreaming...If so, i would love some help making one or a jsfiddle example!

6
  • 2
    i have tried some modals, but they are too complicated...i am only 15, so i am new to this stuff. :) Commented May 1, 2012 at 2:39
  • 1
    Age is not a hindrance. I know a person here that is 14 and is much more superior/geeky than the older guys. Commented May 1, 2012 at 2:40
  • 1
    Age has nothing to do with anything. Don't be silly and never use it as an excuse or reason. Commented May 1, 2012 at 2:40
  • Sorry, do you have an example you can show me... Commented May 1, 2012 at 2:41
  • 1
    @EliteGamer never let age get in the way or be an excuse. It's great that you are only 15 and are learning this stuff early! Good luck to you... Commented May 1, 2012 at 3:27

2 Answers 2

5

Alert boxes are browser specific and cannot be modified.

Your best bet is to use something like jQuery UI dialog.

http://jqueryui.com/demos/dialog/

Here's a pretty simple example...

http://jsfiddle.net/jcreamer898/c4RNq/

Sign up to request clarification or add additional context in comments.

5 Comments

No problem man, I posted an example fiddle for ya as well. Let me know if you need any other help! Feel free to hit me up anytime... about.me/jcreamer898
yes he can change alert dialog, everything is replaceable in prototype based languages
are you sure, look at my answer and try it
What you are doing is replacing the built in alert with your own. technically that works, but I don't believe that's what he was looking for, and it's generally bad juju to replace built in browser functionality...
technically javascript is modeled as prototype language and you shouldn't be afraid to change or adopt features ;) I don't want to argue with you. Basically every undocumented unexpected implementations is bad implementation :) so you could be right here :)
2

you can rewrite alert() function and put in it any jQuery popup plugin, like jQuery UI Dialog

window.alert = function(message){
               $( "#dialog-message" ).html("<p>"+ message + "</p>");
               $( "#dialog-message" ).dialog({
            modal: true,
            buttons: {
                Ok: function() {
                    $( this ).dialog( "close" );
                }
            }
        });

}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.