jquery:Colorbox 关闭 iFrame onsubmit
我有一个关于提交后关闭带有颜色框的表单的问题。我发现了这个问题,所以我现在知道如何在提交后关闭表单。问题是另一个 javascript 验证我表单的输入字段,当某些字段未填写时,将会出现一条错误消息(一个简单的alert())...我想仅在验证返回 no 时关闭 clorbox iframe onsubmit错误..否则用户会得到提示,他错过了一些输入字段,但表单无论如何都会关闭...所以我如何使用 jQuery 检查这一点..是否有可能检查“alert()”是否为显示于屏幕...然后可以说,当显示警报弹出窗口时,不要关闭颜色框窗口,否则关闭它,因为没有错误...有人明白我的意思吗?再次强调:我无法更改验证脚本!然后我可以简单地在这个脚本中添加 .colorbox.close();
...
验证是一个简单的函数,在提交时执行...有一个变量“msg”,其中包含错误消息在这个函数中......必须有一种方法可以在函数执行时获取这个“msg”变量并检查它是否为空......?
谁能帮我解决这个问题...这对我来说有点难以解释..
i´ve got a question about closing a form withing a colorbox after submit. I found this question so i now know how to close the form after submit. The problem is that another javascript validates the input fields of my form and there will be an error message (a simple alert()) when some fields are not filled in...i wanne close the clorbox iframe onsubmit only when the validation returns no error..otherwise the user will get the hint that he missed some input fields but the form will close anyway...so how can i check this with jQuery..is there a possiblity to maybe check if an "alert()" is shown on screen...then is could say, when the alertpopup is shown don´t close the colorbox window, otherwise close it because there was no error...does anyone understand what i mean? Again: I cannot change the validation script! Then i could simply add the .colorbox.close();
within this script...
The validation is a simple function which is executed onsubmit...there is a variable "msg" which contains the errormessage within this function..there must be a way to get this "msg" variable when the function executes and to check whether it´s empty or not....?
Can anyone help me with this...it´s a bit difficult to explain for me..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以通过以下方式引用 iFramed 内容来获取“msg”元素的内容:
在类似的情况下我所做的是这样的:
您可以从插件作者的网站中找到具体操作方法:
阻止 ColorBox 关闭/更改 $.colorbox.close() 的行为
close 方法 ($.colorbox.close()) 可以缓存并重新定义,以便对 ColorBox 关闭时发生的情况提供一些控制。这会影响绑定到它的控件(例如 escKey、overlayClose 和关闭按钮)并直接调用 close 方法。
例如,假设我们打开 ColorBox 来显示包含表单的 html 片段,并且我们想警告访问者,如果他们在提交数据之前尝试关闭 ColorBox,他们将丢弃表单。
You can probably get the contents of the "msg" element from the iFramed content by referring to it this way:
What I have done in a similar situation is this:
You can find out exactly how to do form the plugin author's website:
Prevent ColorBox from closing / Change the behavior of $.colorbox.close()
The close method ($.colorbox.close()) can be cached and redefined as to offer some control over what happens when ColorBox is closed. This affects controls that are bind to it (such as the escKey, overlayClose, and the close button) and calling the close method directly.
For example, lets say we open ColorBox to display an html snippet containing a form, and we want to warn the visitor that they are discarding their form if they try to close ColorBox before they submit their data.