Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check file extention

Status
Not open for further replies.

SimonFinn

Programmer
Mar 13, 2003
130
GB
Hi Guys

I am using this code to check a file extension of a file path listed in a textbox. I have tried changing it to upper case which does not solve it.

Any ideas

Cheers Si

var iLen = String(frmDetails.txtFile.value).length;
if (String(frmDetails.txtFile.value).substring(iLen, iLen - 3) != "doc");
{
mesg = "Please verify your CV File and submit again." & String(frmDetails.txtFile.value).toUpperCase().substring(iLen, iLen - 3)
alert(mesg);
//Return Cursur
frmDetails.txtFile.focus();
//Stop submit
return (false);
}
 
Give this a try, let us know if you have any questions:

Code:
<html><head><script>
function ckext(frm) {
re = /doc/i;
ckstra = frm.tstval.value;
len = ckstra.length;
ckstrb = ckstra.substring(len-3,len);
 if(!ckstrb.match(re)) {
	mesg = 'Check File Name ' + ckstra;
	alert(mesg);
	return false;}
 else {  alert(&quot;\&quot;doc\&quot; ext found&quot;); return true; }
}
</script></head><body>
<form name=&quot;tst&quot;>
<input type=&quot;text&quot; name=&quot;tstval&quot; size=&quot;30&quot;>
<input type=&quot;button&quot; value=&quot;See Ext&quot; 
onClick=&quot;javascript:ckext(this.form);&quot;>
</form></body></html>[\code]

2b||!2b
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top