Click here to Skip to main content
14,919,896 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

I want an alert message to trigger conditionally, i.e if condition is false this alert should trigger.

Dont want any key click etc. event.

What I have tried:

if (state && disc > 100)
					title: 'You have reached the limit or your quota!',
					template: `
					<p> A Message goes here! <p>
					confirmText: 'Accept',
					confirmStyle: 'blue',
					callback: null
				return false;

Code from: This website
Updated 20-Aug-20 2:50am
Richard MacCutchan 20-Aug-20 7:24am
What is the problem?
nyt1972 20-Aug-20 7:27am
Alret not working

1 solution

I am not sure which library you are using to show alert here but quick Google did not give me a result that matched your syntax.

So, suggesting couple of other jQuery based alerts/dialog that can be used. Seems you have condition block in place, all you need is to invoke the alert from there.

Dialog | jQuery UI[^]
<!doctype html>
<html lang="en">
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>jQuery UI Dialog - Default functionality</title>
  <link rel="stylesheet" href="//">
  <link rel="stylesheet" href="/resources/demos/style.css">
  <script src=""></script>
  <script src=""></script>
  $( function() {
    $( "#dialog" ).dialog();
  } );
<div id="dialog" title="Basic dialog">
  <p>This is the default dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the 'x' icon.</p>

Another option:
jquery-confirm.js | The multipurpose alert & confirm[^]
// Would need javascript file references too

    title: 'Alert!',
    content: 'Simple alert!',

There are many, pick a simple one and use it.

BTW, simplest of it is windows.alert: Window alert() Method[^]
nyt1972 20-Aug-20 11:09am
Thanks Sandeep but I wanted a fancy one, and without clicking a button, if I change this textbox value and if the condition is true.
Sandeep Mewara 20-Aug-20 11:12am
Does not this fall into fancy category?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900