473,322 Members | 1,431 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

disabling filename input

How can i restrict user from entering anything in file name of input type
file (upload) control. I want user can ionly select file using browse button
Feb 9 '06 #1
4 1216
Techincally, you cannot do this in the literal sense. This is controlled by
the browser. You could suggest that your user uses Opera, as I believe that
only gives the option to browse.

There are tricks you can play to get the effect you're after, though. Take
a look here. http://www.quirksmode.org/dom/inputfile.html

Ray at work

"Vikram" <aa@aa> wrote in message
news:eg**************@TK2MSFTNGP14.phx.gbl...
How can i restrict user from entering anything in file name of input type
file (upload) control. I want user can ionly select file using browse
button

Feb 9 '06 #2
The browser controls file selection in a rather authoritative manner because
it is a very sensitive area from a security standpoint. Therefore there is
no way to do this with HTML alone. You'd need an ActiveX control or some
other thick client that has been granted permission to handle such matters.

--
I hope this helps,
Steve C. Orr
MCSD, MVP
http://Steve.Orr.net

"Vikram" wrote:
How can i restrict user from entering anything in file name of input type
file (upload) control. I want user can ionly select file using browse button

Feb 9 '06 #3
You could use client side scripting, if you capture the keydown (onkeydown)
event of the file control then you can return without updating the text
element.

in your form 'body' define the following:
<body onkeypress="return onkeyPress(event);">

then you can write script to return onkeypress (I use javascript)

function onkeyPress(e)
{
var key = window.event ? e.keyCode : e.which;
if (key == 13)
StartClick();

e.cancelBubble = true;
e.returnValue = false;
return false;
}

the above will return and and not update any controls. However if 'Enter' is
pressed it will run the 'StartClick' funtion.

"Vikram" wrote:
How can i restrict user from entering anything in file name of input type
file (upload) control. I want user can ionly select file using browse button

Apr 4 '06 #4
just a warning this will effect all other input controls on the form you may
be better adding the keypress event to just the 'file' control.e.g.
<INPUT type="file" onkeypress="return onkeyPress(event);">
"Steven MCP, MCAD" wrote:
You could use client side scripting, if you capture the keydown (onkeydown)
event of the file control then you can return without updating the text
element.

in your form 'body' define the following:
<body onkeypress="return onkeyPress(event);">

then you can write script to return onkeypress (I use javascript)

function onkeyPress(e)
{
var key = window.event ? e.keyCode : e.which;
if (key == 13)
StartClick();

e.cancelBubble = true;
e.returnValue = false;
return false;
}

the above will return and and not update any controls. However if 'Enter' is
pressed it will run the 'StartClick' funtion.

"Vikram" wrote:
How can i restrict user from entering anything in file name of input type
file (upload) control. I want user can ionly select file using browse button

Apr 4 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Ashish Shridharan | last post by:
Hi All, Has anyone ever tried disabling a checkbox or a radiobutton web server control in netscape ? While a textbox and a button control renders disabled, .NET adds the disabled attribute to...
1
by: Matt | last post by:
In test() method: var path="C:\test\hello.txt"; //returns -1 for path.lastIndexOf("\\"). why?? var pos=path.lastIndexOf("\\"); //return -1 But in showFile() method: We are able to get the...
12
by: Sharad Gupta | last post by:
i have this problem of capturing the filename on the instance when onclick is activated in the <body> the function should catch the filename and display it. Second problem, i have to catch the...
2
by: Xam | last post by:
Hello everybody Do you know of a javascript routine that can warn if there are any pre-defined invalid chars in the filename of an INPUT file box before it is submitted with the submit button. ...
6
by: ML.Steve | last post by:
Hi, There are lots of posts on this subject but after a couple of hours of going though them I still can't get a number of fields to be disabled when a checkbox is ticked. Basically I have a...
1
by: Evelyne | last post by:
I create CheckBoxes on the fly. I want to disable the CheckBoxes when they reflect Status, so the operator does not try to input anything. However, the text/label of the CheckBox gets grayed out...
10
by: Brian Gruber | last post by:
Hi, I'm looking for a way to rename a whole directory of files in short order. The files in the directory have different lengths, however all of them end with _xxxx the x's represent a randomly...
1
by: kebabkongen | last post by:
Hi, I'm working on a JavaScript that is enabling / disabling a select element according to whether a checkbox is selected or not. This works fine in Firefox, but in Internet Explorer (v 6.0.2900)...
1
by: chennaibala | last post by:
can any one send me mutiple image upload program and save the file name with extension in mysql table.we must cheak uploaded file type like bmp or any image file while uploading. i develop...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.