All hosting is offered in your choice of 12 worldwide hosting locations. All Data Centers are are SSAE16, SOC, PCI, and HIPAA-Compliant. ISO 9001: 2008 for quality management systems and ISO/IEC 27001:2005 for information security management systems.
Your choice of 18 hosting locations worldwide. New York City, San Francisco, Toronto, London, Paris, Frankfurt, Stockholm, Amsterdam, Madrid, Warsaw, Mexico City, Sao Paulo, Santiago, Johannesburg, Seoul, Singapore, Tokyo, and Sydney.
Certified Data Centers
Cited, Inc. provides services to customers in over 80 countries worldwide. SSAE16, SOC, PCI, and HIPAA-Compliant. ISO 9001: 2008 for quality management systems and ISO/IEC 27001:2005 for information security management systems.
Your choice of 18 hosting locations worldwide. New York City, San Francisco, Toronto, London, Paris, Frankfurt, Stockholm, Amsterdam, Madrid, Warsaw, Mexico City, Sao Paulo, Santiago, Johannesburg, Seoul, Singapore, Tokyo, and Sydney.
Certified Data Centers
Cited, Inc. provides services to customers in over 80 countries worldwide. SSAE16, SOC, PCI, and HIPAA-Compliant. ISO 9001: 2008 for quality management systems and ISO/IEC 27001:2005 for information security management systems.
Your choice of 18 hosting locations worldwide. New York City, San Francisco, Toronto, London, Paris, Frankfurt, Stockholm, Amsterdam, Madrid, Warsaw, Mexico City, Sao Paulo, Santiago, Johannesburg, Seoul, Singapore, Tokyo, and Sydney.
Certified Data Centers
Cited, Inc. provides services to customers in over 80 countries worldwide. SSAE16, SOC, PCI, and HIPAA-Compliant. ISO 9001: 2008 for quality management systems and ISO/IEC 27001:2005 for information security management systems.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<h2>A beautiful replacement for JavaScript's "Alert"</h2>
<buttonclass="download">Download</button>
<!-- What does it do? -->
<h3>So... What does it do?</h3>
<p>Here’s a comparison of a standard error message. The first one uses the built-in <strong>alert</strong>-function, while the second is using <strong>sweetAlert</strong>.</p>
<divclass="showcase normal">
<h4>Normal alert</h4>
<button>Show error message</button>
<h5>Code:</h5>
<pre><spanclass="attr">alert</span>(<spanclass="str">"Oops... Something went wrong!"</span>);
</pre>
<divclass="vs-icon"></div>
</div>
<divclass="showcase sweet">
<h4>Sweet Alert</h4>
<button>Show error message</button>
<h5>Code:</h5>
<pre><spanclass="attr">sweetAlert</span>(<spanclass="str">"Oops..."</span>, <spanclass="str">"Something went wrong!"</span>, <spanclass="str">"error"</span>);</pre>
</div>
<p>Pretty cool huh? SweetAlert automatically centers itself on the page and looks great no matter if you're using a desktop computer, mobile or tablet. It's even highly customizeable, as you can see below!</p>
<!-- Examples -->
<h3>More examples</h3>
<pclass="center">In these examples, we're using the shorthand function <strong>swal</strong> to call sweetAlert.</p>
<ulclass="examples">
<liclass="message">
<divclass="ui">
<p>A basic message</p>
<button>Try me!</button>
</div>
<pre><spanclass="attr">swal</span>(<spanclass="str">"Here's a message!"</span>)</pre>
</li>
<liclass="title-text">
<divclass="ui">
<p>A title with a text under</p>
<button>Try me!</button>
</div>
<pre><spanclass="attr">swal</span>(<spanclass="str">"Here's a message!"</span>, <spanclass="str">"It's pretty, isn't it?"</span>)</pre>
</li>
<liclass="success">
<divclass="ui">
<p>A success message!</p>
<button>Try me!</button>
</div>
<pre><spanclass="attr">swal</span>(<spanclass="str">"Good job!"</span>, <spanclass="str">"You clicked the button!"</span>, <spanclass="str">"success"</span>)</pre>
</li>
<liclass="warning confirm">
<divclass="ui">
<p>A warning message, with a function attached to the "Confirm"-button...</p>
<button>Try me!</button>
</div>
<pre><spanclass="attr">swal</span>({
title: <spanclass="str">"Are you sure?"</span>,
text: <spanclass="str">"You will not be able to recover this imaginary file!"</span>,
<spanclass="attr">swal</span>(<spanclass="str">"Deleted!"</span>, <spanclass="str">"Your imaginary file has been deleted."</span>, <spanclass="str">"success"</span>);
});</pre>
</li>
<liclass="warning cancel">
<divclass="ui">
<p>... and by passing a parameter, you can execute something else for "Cancel".</p>
<button>Try me!</button>
</div>
<pre><spanclass="attr">swal</span>({
title: <spanclass="str">"Are you sure?"</span>,
text: <spanclass="str">"You will not be able to recover this imaginary file!"</span>,
<spanclass="attr">swal</span>(<spanclass="str">"Deleted!"</span>, <spanclass="str">"Your imaginary file has been deleted."</span>, <spanclass="str">"success"</span>);
} <spanclass="tag">else</span> {
<spanclass="attr">swal</span>(<spanclass="str">"Cancelled"</span>, <spanclass="str">"Your imaginary file is safe :)"</span>, <spanclass="str">"error"</span>);
<pclass="center">Here are the keys that you can use if you pass an object into sweetAlert:</p>
<table>
<trclass="titles">
<th>
<divclass="border-left"></div>
Argument
</th>
<th>Default value</th>
<th>
<divclass="border-right"></div>
Description
</th>
</tr>
<tr>
<td><b>title</b></td>
<td><i>null (required)</i></td>
<td>The title of the modal. It can either be added to the object under the key "title" or passed as the first parameter of the function.</td>
</tr>
<tr>
<td><b>text</b></td>
<td><i>null</i></td>
<td>A description for the modal. It can either be added to the object under the key "text" or passed as the second parameter of the function.</td>
</tr>
<tr>
<td><b>type</b></td>
<td><i>null</i></td>
<td>The type of the modal. SweetAlert comes with 4 built-in types which will show a corresponding icon animation: "<strong>warning</strong>", "<strong>error</strong>", "<strong>success</strong>" and "<strong>info"</strong>. You can also set it as "<strong>input</strong>" to get a prompt modal. It can either be put in the object under the key "type" or passed as the third parameter of the function.</td>
</tr>
<tr>
<td><b>allowEscapeKey</b></td>
<td><i>true</i></td>
<td>If set to <strong>true</strong>, the user can dismiss the modal by pressing the Escape key.</td>
</tr>
<tr>
<td><b>customClass</b></td>
<td><i>null</i></td>
<td>A custom CSS class for the modal. It can be added to the object under the key "customClass".</td>
</tr>
<tr>
<td><b>allowOutsideClick</b></td>
<td><i>false</i></td>
<td>If set to <strong>true</strong>, the user can dismiss the modal by clicking outside it.</td>
</tr>
<tr>
<td><b>showCancelButton</b></td>
<td><i>false</i></td>
<td>If set to <strong>true</strong>, a "Cancel"-button will be shown, which the user can click on to dismiss the modal.</td>
</tr>
<tr>
<td><b>showConfirmButton</b></td>
<td><i>true</i></td>
<td>If set to <strong>false</strong>, the "OK/Confirm"-button will be hidden. Make sure you set a timer or set allowOutsideClick to true when using this, in order not to annoy the user.</td>
</tr>
<tr>
<td><b>confirmButtonText</b></td>
<td><i>"OK"</i></td>
<td>Use this to change the text on the "Confirm"-button. If showCancelButton is set as true, the confirm button will automatically show "Confirm" instead of "OK".</td>
</tr>
<tr>
<td><b>confirmButtonColor</b></td>
<td><i>"#AEDEF4"</i></td>
<td>Use this to change the background color of the "Confirm"-button (must be a HEX value).</td>
</tr>
<tr>
<td><b>cancelButtonText</b></td>
<td><i>"Cancel"</i></td>
<td>Use this to change the text on the "Cancel"-button.</td>
</tr>
<tr>
<td><b>closeOnConfirm</b></td>
<td><i>true</i></td>
<td>Set to <i>false</i> if you want the modal to stay open even if the user presses the "Confirm"-button. This is especially useful if the function attached to the "Confirm"-button is another SweetAlert.</td>
</tr>
<tr>
<td><b>closeOnCancel</b></td>
<td><i>true</i></td>
<td>Same as closeOnConfirm, but for the cancel button.</td>
</tr>
<tr>
<td><b>imageUrl</b></td>
<td><i>null</i></td>
<td>Add a customized icon for the modal. Should contain a string with the path to the image.</td>
</tr>
<tr>
<td><b>imageSize</b></td>
<td><i>"80x80"</i></td>
<td>If imageUrl is set, you can specify imageSize to describes how big you want the icon to be in px. Pass in a string with two values separated by an "x". The first value is the width, the second is the height.</td>
</tr>
<tr>
<td><b>timer</b></td>
<td><i>null</i></td>
<td>Auto close timer of the modal. Set in ms (milliseconds).</td>
</tr>
<tr>
<td><b>html</b></td>
<td><i>false</i></td>
<td>If set to true, will not escape title and text parameters. (Set to false if you're worried about XSS attacks.)</td>
</tr>
<tr>
<td><b>animation</b></td>
<td><i>true</i></td>
<td>If set to <strong>false</strong>, the modal's animation will be disabled. Possible (string) values : <strong>pop</strong> (default when animation set to true), <strong>slide-from-top</strong>, <strong>slide-from-bottom</strong></td>
</tr>
<tr>
<td><b>inputType</b></td>
<td><i>"text"</i></td>
<td>Change the type of the input field when using <strong>type: "input"</strong> (this can be useful if you want users to type in their password for example).</td>
</tr>
<tr>
<td><b>inputPlaceholder</b></td>
<td><i>null</i></td>
<td>When using the input-type, you can specify a placeholder to help the user.</td>
</tr>
<tr>
<td><b>inputValue</b></td>
<td><i>null</i></td>
<td>Specify a default text value that you want your input to show when using <strong>type: "input"</strong></td>
</tr>
<tr>
<td><b>showLoaderOnConfirm</b></td>
<td><i>false</i></td>
<td>Set to <strong>true</strong> to disable the buttons and show that something is loading.</td>
</tr>
</table>
<!-- Methods -->
<h3>Methods</h3>
<pclass="center">SweetAlert also comes with some simple methods that you can call:</p>
<td>If you end up using a lot of the same settings when calling SweetAlert, you can use setDefaults at the start of your program to set them once and for all!</td>
</tr>
<tr>
<td>close</td>
<td><i>swal.close();</i></td>
<td>Close the currently open SweetAlert programatically.</td>
<td>Show an error message after validating the input field, if the user's data is bad</td>
</tr>
<tr>
<td>enableButtons, disableButtons</td>
<td><i>swal.disableButtons();</i></td>
<td>Disable or enable the user to click on the cancel and confirm buttons.</td>
</tr>
</table>
<!-- Contribute -->
<h3>Contribute</h3>
<p>SweetAlert was created by <ahref="http://tristanedwards.me"target="_blank">Tristan Edwards</a>, you can follow him on <ahref="https://twitter.com/t4t5"target="_blank"class="twitter">Twitter</a> or <ahref="https://dribbble.com/tristanedwards"target="_blank"class="dribbble">Dribbble</a> for updates and other cool projects!</p>
<p>Feel free to fork SweetAlert on <ahref="https://github.com/t4t5/sweetalert"class="github">GitHub</a> if you have any features that you want to add!</p>