Click here to Skip to main content
15,884,836 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
In my application I am using a HTML tag.

HTML
<input type="file"  id="filename" name="filename" size="50" required onchange="return Checkfiles();"/>  

It's working fine, when i press submit button. But when i press Cancel button to redirect to some other page, it's still showing required field missing error.Please help

Thanks in advence.
Posted
Updated 6-Oct-13 19:47pm
v2
Comments
Azee 7-Oct-13 1:35am    
Can you please add Button's code and JavaScript function as well in your Question?
srmohanr 7-Oct-13 1:36am    
can you please give me an example for this. Thanks
Azee 7-Oct-13 2:02am    
I mean, post the Buttons of aspx page and the JavaScript function implementation.
Brij 7-Oct-13 2:05am    
Can you post code for Checkfiles here? Also check if Checkfiles is fired on cancel button?
srmohanr 7-Oct-13 2:07am    
<script type="text/javascript">
function Checkfiles() {
var fup = document.getElementById('filename');
var fileName = fup.value;
var ext = fileName.substring(fileName.lastIndexOf('.') + 1);
if (ext == "gif" || ext == "GIF" || ext == "JPEG" || ext == "jpeg" || ext == "jpg" || ext == "JPG" || ext == "doc") {
return true;
}
else {
alert("Upload Gif or Jpg images only");
fup.focus();
return false;
}
}
</script>

1 solution

You need to add formnovalidate content attribute to your html control.
Eg.

HTML
<input type=submit formnovalidate name=cancel value="Cancel">


Refer this link :

no-validate state[^]

I hope It will help you.

Good luck.
 
Share this answer
 
v2
Comments
srmohanr 7-Oct-13 2:48am    
Thanks. It's working fine now. Now I need to redirect to another aspx page. How can I do that. Please help
Raje_ 7-Oct-13 2:49am    
You are Welcome, glad to know, It worked.

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