IE9:验证消息未清除
我正在使用仅接受图像文件的上传控件。如果我选择任何非图像文件,我将显示一条验证错误消息“文件类型无效”。我使用的上传控件如下
<UC:UploadControl runat="server" ID="file_logo" IsRequired="false" ReqValidationGroup="jpg" onkeypress="Javascript:CheckNumeric(event);" RequiredFieldMessage="Please upload Image file" CheckFileType="true" Width="870" Height="100" CheckDimension="false" RegexpFieldMessage="File type is invalid." FileFormats="gif,GIF,jpg,JPG,jpeg,JPEG" RegDisplay="true" />
我使用另一个链接来清除错误验证消息。代码是
<a href='javascript:chkFileTypes("ctl00_mainContentPlaceHolder_file_logo_uploadfiles");clearInvalidLabel("ctl00_mainContentPlaceHolder_file_logo_uploadfiles")' >Clear File</a><br />
我的Javascript函数,用于清除验证消息
function clearInvalidLabel(control) {
if (control == "ctl00_mainContentPlaceHolder_file_logo_uploadfiles") $("span[id$='file_logo_regexpType']").hide();
if (control == "ctl00_mainContentPlaceHolder_PopUp_logo_uploadfiles") $("span[id$='PopUp_logo_regexpType']").hide();}
现在,如果我再次使用UploadControl选择不正确的文件,则不会显示错误验证消息(仅在IE9中)。它在其他浏览器中完美运行。请帮帮我。
谢谢。
I am using an upload control which accepts only image files.If I select any non-image files I will be showing a validation error message "File type is invalid". The upload control i use is as follows
<UC:UploadControl runat="server" ID="file_logo" IsRequired="false" ReqValidationGroup="jpg" onkeypress="Javascript:CheckNumeric(event);" RequiredFieldMessage="Please upload Image file" CheckFileType="true" Width="870" Height="100" CheckDimension="false" RegexpFieldMessage="File type is invalid." FileFormats="gif,GIF,jpg,JPG,jpeg,JPEG" RegDisplay="true" />
I use another link to clear the error validation message. The code is
<a href='javascript:chkFileTypes("ctl00_mainContentPlaceHolder_file_logo_uploadfiles");clearInvalidLabel("ctl00_mainContentPlaceHolder_file_logo_uploadfiles")' >Clear File</a><br />
My Javascript function used to clear validation message is
function clearInvalidLabel(control) {
if (control == "ctl00_mainContentPlaceHolder_file_logo_uploadfiles") $("span[id$='file_logo_regexpType']").hide();
if (control == "ctl00_mainContentPlaceHolder_PopUp_logo_uploadfiles") $("span[id$='PopUp_logo_regexpType']").hide();}
Now if I again select an improper file using UploadControl, the error validation message is not getting displayed(Only in IE9). It works perfectly in other browsers. Please help me out.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
硬编码 ID 很容易被破解。尝试使用
ClientID
在 JavaScript 中访问该控件。我也会使用 ClientID 来获取验证标签:
Hard-coding IDs is easy to break. Try using the
ClientID
to access the control in JavaScript.I would use the ClientID to get the validation labels too: