Click here to Skip to main content
15,911,646 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi friends,

i have one jsp file called as file_upload.jsp and one java script file called file_upload.js.In jsp page i have a field as file upload and the id is file_upload.For this if i did not enter the file upload field and going then it is displaying the alert message as please select a file to upload but it is not focusing on the textfield.My requirement is it has to focus on the field wherever i forget to enter the values(the error comes).My code is as follows.

C#
if (file_upload == "") {
            alert("Please select a file to Upload !!");
            document.getElementById('file_upload').focus();
            return false; }

Any thing wrong in my code or any thing extra i have to add.This is very urgent to me any ones help will be greately appreciated.
Posted

1 solution

I don't think it's possible to make the file upload control the focus, just as it's not possible to get the text from it, for security reasons.
 
Share this answer
 
Comments
komali Guntur 27-Jul-11 14:16pm    
ok Graus for file upload take it easy the same problem is for sender name also the code is as follows.
if (sender_name == "") {
alert("Sender Name is Mandatory Feild !!");
document.getElementById('sender_name').focus();
return false;
}

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