开发者

IE9: Validation message not getting cleared

开发者 https://www.devze.com 2023-04-08 07:47 出处:网络
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 follow

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_mainContent开发者_StackOverflowPlaceHolder_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.


Hard-coding IDs is easy to break. Try using the ClientID to access the control in JavaScript.

<a href='javascript:chkFileTypes("<%=UploadFilesControl.ClientID%>");clearInvalidLabel("<%=UploadFilesControl.ClientID%>")'>Clear File</a> 

I would use the ClientID to get the validation labels too:

$("#<%=regexpType.ClientID%>").hide();    
0

精彩评论

暂无评论...
验证码 换一张
取 消