JavaScript验证图片类型(扩展名)的函数分享
时间:2024-04-17 09:51:00
前台调用如下
OnClientClick="return fucCheckJpgAndGif(form1.File1.value);" --其中File1为上传文件控件
函数代码:
function fucCheckJpgAndGif(strFileName) {
if (strFileName != "") {
var strtype = strFileName.substring(strFileName.length - 4, strFileName.length);
strtype = strtype.toLowerCase();
if ((strtype == ".jpg") || (strtype == ".gif") || (strtype == "jpeg") || (strtype == ".bmp")) {
return true;
}
else {
alert("请上传jpg、gif或者bmp格式的图片,谢谢!");
return false;
}
}
alert("请上传jpg、gif或者bmp格式的图片,谢谢!");/* from http://yige.org/js/ */
return false;
}
标签:JavaScript,图片类型
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
mybatis统计每条SQL的执行时间的方法示例
2024-01-28 12:54:43
Python中使用MELIAE分析程序内存占用实例
2021-10-26 22:34:24
sql 存储过程批量删除数据的语句
2024-01-21 17:40:23
Python淘宝或京东等秒杀抢购脚本实现(秒杀脚本)
2023-01-23 20:25:14
![](https://img.aspxhome.com/file/2023/0/125000_0s.png)
sqlserver bcp(数据导入导出工具)一般用法与命令详解
2024-01-27 03:12:08
使用pandas模块读取csv文件和excel表格,并用matplotlib画图的方法
2023-10-04 14:42:58
![](https://img.aspxhome.com/file/2023/1/115661_0s.jpg)
SqlServer服务中利用触发器对指定账户进行登录ip限制提升安全性操作
2024-01-26 12:24:32
![](https://img.aspxhome.com/file/2023/0/94440_0s.png)
python读取nc数据并绘图的方法实例
2023-09-16 10:08:19
![](https://img.aspxhome.com/file/2023/8/91868_0s.png)
Python函数装饰器的使用教程
2022-10-26 03:01:06
![](https://img.aspxhome.com/file/2023/2/131572_0s.png)
PHP文件操作详解
2023-11-20 07:44:25
利用索引提高SQL Server数据处理的效率
2009-01-08 15:32:00
Java动态-代理实现AOP
2023-07-15 09:33:43
使用Python实现牛顿法求极值
2021-10-14 15:10:21
![](https://img.aspxhome.com/file/2023/7/131357_0s.jpg)
IronPython连接MySQL的方法步骤
2024-01-27 05:43:05
MySQL数据库入门之备份数据库操作详解
2024-01-24 07:10:05
Hive-SQL查询连续活跃登录用户思路详解
2024-01-22 08:29:47
![](https://img.aspxhome.com/file/2023/2/113552_0s.png)
python3的pip路径在哪
2023-01-27 14:15:39
pyhton学习与数据挖掘self原理及应用分析
2023-07-04 23:19:11
基于vue实现微博三方登录流程解析
2024-05-03 15:08:42
![](https://img.aspxhome.com/file/2023/5/130225_0s.png)
给textarea增加长度限制的几种方法
2009-06-04 12:27:00