Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Trying to set a window alert method but having trouble doing so. Is it possible to do it with this code:

JavaScript
messages: {
       name: { required: "Please enter name"
              },
              email: {
                  required: "Please enter an email!"
              },
          },

Tried this code:
JavaScript
alert('');


in and around the required function, but somehow it still doesn't work. Any ideas?
Posted
Comments
Sergey Alexandrovich Kryukov 13-Jan-15 18:43pm    
What doesn't work, alert(''); how should it possibly work? By showing empty dialog box?
—SA

It's not clear what exactly you are trying to achieve and why would you try to show empty alert dialog box. Your data structure above suggests that you are trying to prompt the user for entering name and e-mail. Javascript alert is not suitable for prompts; it is merely the alert which is hardly good enough for the use in well-developed UI.

It would be the best to avoid any promptс at all. This is quite possible in most cases. You can put input controls just on the page and let the user fill them and click on some "Submit" button whenever this person is ready. However, if your really want to show a real prompt, with some modal behavior, you can use, for example, jQuery Dialog instead:
http://jqueryui.com/dialog[^].

If you need to learn jQuery (highly recommended), please see:
http://en.wikipedia.org/wiki/JQuery[^],
http://jquery.com[^],
http://learn.jquery.com[^],
http://learn.jquery.com/using-jquery-core[^],
http://learn.jquery.com/about-jquery/how-jquery-works[^] (start from here).

—SA
 
Share this answer
 
v2
This is what you are looking for:

http://jsfiddle.net/U6N3R/[^]
 
Share this answer
 
v2

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