...

View Full Version : check file extension in a form



sushestvo
08-29-2005, 06:23 PM
So I have a form...
File: _______________ [Browse]
Name: _____________
[Submit]

when person chooses file by browse button I want submit button to disable when file has extension that is not .txt or .doc
how can I do that?

vwphillips
08-29-2005, 06:55 PM
Enter the text and blur<br />
Use your own method to call Ck()<br />
<input size="10" onblur="Ck(this);" />

<script language="JavaScript" type="text/javascript">
/*<![CDATA[*/
function Ck(obj){
val=obj.value.substring(obj.value.length-4,obj.value.length);
if (val!='.txt'&&val!='.doc'){
alert(val+' is not .txt or .doc');
return false;
}
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum