如何设置窗口警报 [英] How Do I Set A Window Alert

查看:81
本文介绍了如何设置窗口警报的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试设置窗口警报方法但无法执行此操作。是否可以使用此代码:



Trying to set a window alert method but having trouble doing so. Is it possible to do it with this code:

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



试过这段代码:


Tried this code:

alert('');





所需功能及其周围,但不知何故它仍然无法正常工作。有什么想法吗?



in and around the required function, but somehow it still doesn't work. Any ideas?

推荐答案

目前还不清楚你究竟想要实现什么,为什么要尝试显示空警告对话框。上面的数据结构表明您正在尝试提示用户输入姓名和电子邮件。 Javascript alert 不适合提示;它仅仅是在完善的UI中使用的警报,它几乎不够好。



最好避免任何提示。在大多数情况下,这是完全可能的。您可以将输入控件放在页面上,让用户填写它们,并在此人准备就绪时单击提交按钮。但是,如果你真的想要显示一个真实的提示,有一些模态行为,你可以使用,例如,jQuery Dialog 代替:

< a href =http://jqueryui.com/dialog> http://jqueryui.com/dialog [ ^ ]。



如果您需要学习jQuery(强烈推荐),请参阅:

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 [ ^ ](从这里开始)。



-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


这就是你要找的东西:



http://jsfiddle.net/U6N3R/ [ ^ ]
This is what you are looking for:

http://jsfiddle.net/U6N3R/[^]


这篇关于如何设置窗口警报的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆