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!
-
2i have tried some modals, but they are too complicated...i am only 15, so i am new to this stuff. :)Hunter Mitchell– Hunter Mitchell2012-05-01 02:39:39 +00:00Commented May 1, 2012 at 2:39
-
1Age is not a hindrance. I know a person here that is 14 and is much more superior/geeky than the older guys.Joseph– Joseph2012-05-01 02:40:11 +00:00Commented May 1, 2012 at 2:40
-
1Age has nothing to do with anything. Don't be silly and never use it as an excuse or reason.Mahmoud Al-Qudsi– Mahmoud Al-Qudsi2012-05-01 02:40:13 +00:00Commented May 1, 2012 at 2:40
-
Sorry, do you have an example you can show me...Hunter Mitchell– Hunter Mitchell2012-05-01 02:41:31 +00:00Commented 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...jcreamer898– jcreamer8982012-05-01 03:27:32 +00:00Commented May 1, 2012 at 3:27
|
Show 1 more comment
2 Answers
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...
5 Comments
jcreamer898
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
Milan Jaric
yes he can change alert dialog, everything is replaceable in prototype based languages
Milan Jaric
are you sure, look at my answer and try it
jcreamer898
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...Milan Jaric
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 :)
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" );
}
}
});
}