Prevent Onclick Anchor Function From Calling Again on Enter Key From Php
SweetAlert2
A beautiful, responsive, customizable, accessible (WAI-ARIA) replacement for JavaScript'southward popup boxes
Cipher dependencies
Download CDNNormal alert
alarm('Oops! Something went incorrect!')
SugarinessAlert2
swal( 'Oops...', 'Something went wrong!', 'fault' )
Pretty cool huh? SweetAlert2 automatically centers itself on the folio and looks great no matter if you're using a desktop figurer, mobile or tablet. It'south fifty-fifty highly customizeable, as y'all tin see below!
More examples
-
A title with a text under
swal( 'The Net?', 'That affair is however around?', 'question' )
-
swal( 'Practiced job!', 'You lot clicked the button!', 'success' )
-
Custom HTML description and buttons with ARIA labels
swal({ title: '<i>HTML</i> <u>example</u>', type: 'info', html: 'You can use <b>assuming text</b>, ' + '<a href="//github.com">links</a> ' + 'and other HTML tags', showCloseButton: truthful, showCancelButton: true, focusConfirm: false confirmButtonText: '<i form="fa fa-thumbs-up"></i> Great!', confirmButtonAriaLabel: 'Thumbs up, cracking!', cancelButtonText: '<i form="fa fa-thumbs-down"></i>', cancelButtonAriaLabel: 'Thumbs down', })
-
swal({ title: 'jQuery HTML instance', html: $('<div>') .addClass('some-class') .text('jQuery is everywhere.'), animation: simulated, customClass: 'animated tada' })
-
A alert message, with a role attached to the "Confirm"-push button...
swal({ title: 'Are you sure?', text: "You won't be able to revert this!", type: 'warning', showCancelButton: true, confirmButtonColor: '#3085d6', cancelButtonColor: '#d33', confirmButtonText: 'Aye, delete it!' }).then( part () { swal( 'Deleted!', 'Your file has been deleted.', 'success' ) })
-
... and by passing a parameter, you can execute something else for "Abolish".
swal({ championship: 'Are you certain?', text: "Yous won't be able to revert this!", blazon: 'warning', showCancelButton: truthful, confirmButtonColor: '#3085d6', cancelButtonColor: '#d33', confirmButtonText: 'Yes, delete it!', cancelButtonText: 'No, abolish!', confirmButtonClass: 'btn btn-success', cancelButtonClass: 'btn btn-danger', buttonsStyling: false }).so( part () { swal( 'Deleted!', 'Your file has been deleted.', 'success' ) }, office (dismiss) { if (dismiss === 'cancel') { swal( 'Cancelled', 'Your imaginary file is safe :)', 'error' ) } })
-
A bulletin with a custom image and CSS blitheness disabled
swal({ championship: 'Sweet!', text: 'Modal with a custom image.', imageUrl: 'https://unsplash.it/400/200', imageWidth: 400, imageHeight: 200, imageAlt: 'Custom image', animation: false })
-
A message with custom width, padding and groundwork
swal({ championship: 'Custom width, padding, groundwork.', width: 600, padding: 100, background: '#fff url(//bit.ly/1Nqn9HU)' })
-
A message with auto close timer
swal({ title: 'Automobile close alert!', text: 'I will shut in 5 seconds.', timer: 5000, onOpen: function () { swal.showLoading() } }).and so( function () {}, function (dismiss) { if (dismiss === 'timer') { console.log('I was airtight by the timer') } } )
-
swal({ title: 'Submit email to run ajax request', input: 'electronic mail', showCancelButton: truthful, confirmButtonText: 'Submit', showLoaderOnConfirm: true, preConfirm: function (email) { return new Promise( role (resolve, reject) { setTimeout(function() { if (e-mail === 'taken@instance.com') { reject('This electronic mail is already taken.') } else { resolve() } }, 2000) }) }, allowOutsideClick: false }).then( part (electronic mail) { swal({ type: 'success', title: 'Ajax request finished!', html: 'Submitted email: ' + email }) })
-
Chaining modals (queue) case
swal.setDefaults({ input: 'text', confirmButtonText: 'Adjacent →', showCancelButton: truthful, blitheness: false, progressSteps: ['1', '2', '3'] }) var steps = [ { title: 'Question 1', text: 'Chaining swal2 modals is like shooting fish in a barrel' }, 'Question two', 'Question 3' ] swal.queue(steps).then( function (result) { swal.resetDefaults() swal({ title: 'All done!', html: 'Your answers: <pre>' + JSON.stringify(effect) + '</pre>', confirmButtonText: 'Lovely!' }) }, function () { swal.resetDefaults() })
-
swal.queue([{ title: 'Your public IP', confirmButtonText: 'Testify my public IP', text: 'Your public IP will exist received ' + 'via AJAX request', showLoaderOnConfirm: truthful, preConfirm: function () { render new Hope( function (resolve) { $.get('https://api.ipify.org?format=json') .done( office (information) { swal.insertQueueStep(information.ip) resolve() }) }) } }])
Usage
1. Initialize the plugin by referencing the necessary files:
<script src="bower_components/sweetalert2/dist/sweetalert2.min.js"></script> <link rel="stylesheet" href="bower_components/sweetalert2/dist/sweetalert2.min.css"> <script src="https://cdnjs.cloudflare.com/ajax/libs/core-js/2.4.1/core.js"></script>
Or
import swal from 'sweetalert2' const swal = require('sweetalert2')
ii. Call the sweetAlert2-function after the page has loaded
swal({ title: 'Fault!', text: 'Practice you want to continue', type: 'error', confirmButtonText: 'Cool' })
Treatment Dismissals
When an alert is dismissed by the user, the Promise returned by swal() will reject with a string documenting the reason it was dismissed:
String | Description | Related configuration |
---|---|---|
'overlay' | The user clicked the overlay. | allowOutsideClick |
'cancel' | The user clicked the cancel button. | showCancelButton |
'close' | The user clicked the close push button. | showCloseButton |
'esc' | The user clicked the Esc key. | allowEscapeKey |
'timer' | The timer ran out, and the alert closed automatically. | timer |
If rejections are non handled, it will be logged as an error. To avoid this, add a rejection handler to the Promise.
Alternatively, yous tin can use .catch(swal.noop) as a quick way to only suppress the errors:
swal(...) .catch(swal.noop)
Modal Types
success | ||
mistake | ||
warning | ||
info | ||
question |
Input Types
text | swal({ title: 'What is your name?', input: 'text', inputPlaceholder: 'Enter your proper name or nickname', showCancelButton: true, inputValidator: function (value) { return new Promise( function (resolve, pass up) { if (value) { resolve() } else { decline('Y'all demand to write something!') } }) } }).so( function (name) { swal({ type: 'success', title: 'Hi, ' + name }) }) | |
electronic mail | swal({ title: 'Input email accost', input: 'email', inputPlaceholder: 'Enter your email accost' }).then( function (email) { swal({ blazon: 'success', html: 'Entered email: ' + email }) }) | |
url | swal({ input: 'url', inputPlaceholder: 'Enter the URL' }).then( role (url) { swal({ type: 'success', html: 'Entered URL: ' + url }) }) | |
countersign | swal({ championship: 'Enter your password', input: 'password', inputPlaceholder: 'Enter your countersign', inputAttributes: { 'maxlength': x, 'autocapitalize': 'off', 'autocorrect': 'off' } }).then( function (password) { if (password) { swal({ type: 'success', html: 'Entered password: ' + password }) } }) | |
textarea | swal({ input: 'textarea', inputPlaceholder: 'Type your message hither', showCancelButton: true }).then( role (text) { if (text) { swal(text) } }) | |
select | swal({ title: 'Select Ukraine', input: 'select', inputOptions: { 'SRB': 'Serbia', 'UKR': 'Ukraine', 'HRV': 'Croatia' }, inputPlaceholder: 'Select land', showCancelButton: true, inputValidator: function (value) { return new Promise( function (resolve, decline) { if (value === 'UKR') { resolve() } else { decline('Yous demand to select Ukraine :)') } }) } }).then( function (result) { swal({ type: 'success', html: 'You selected: ' + effect }) }) | |
radio | var inputOptions = new Promise( function (resolve) { setTimeout( function () { resolve({ '#ff0000': 'Red', '#00ff00': 'Greenish', '#0000ff': 'Blue' }) }, 2000) }) swal({ title: 'Select color', input: 'radio', inputOptions: inputOptions, inputValidator: office (upshot) { return new Promise( function (resolve, decline) { if (result) { resolve() } else { reject('You need to select something!') } }) } }).then( function (issue) { swal({ blazon: 'success', html: 'You selected: ' + effect }) }) | |
checkbox | swal({ championship: 'Terms and conditions', input: 'checkbox', inputValue: one, inputPlaceholder: 'I agree with the terms and atmospheric condition', confirmButtonText: 'Go along <i grade="fa fa-arrow-right></i>', inputValidator: function (result) { return new Promise( role (resolve, reject) { if (result) { resolve() } else { reject('You need to agree with T&C') } }) } }).then( part (issue) { swal({ type: 'success', text: 'Yous agreed with T&C :)' }) }) | |
file | swal({ title: 'Select paradigm', input: 'file', inputAttributes: { 'accept': 'paradigm/*', 'aria-characterization': 'Upload your profile picture' } }).then( function (file) { var reader = new FileReader reader.onload = part (e) { swal({ title: 'Your uploaded pic' imageUrl: e.target.result, imageAlt: 'The uploaded flick' }) } reader.readAsDataURL(file) }) | |
range | swal({ championship: 'How former are you lot?', type: 'question', input: 'range', inputAttributes: { min: viii, max: 120, step: 1 }, inputValue: 25 }) |
Collaborators
Donations
Has SweetAlert2 helped you create an amazing awarding?
Y'all tin can show your support by making a donation in one of two ways:
Contribute
Feel gratis to fork SweetAlert2 on GitHub if yous have whatever features that yous want to add together!
Source: https://kepriprov.go.id/assets/plugins/sweetalert/
0 Response to "Prevent Onclick Anchor Function From Calling Again on Enter Key From Php"
Post a Comment