Home > Web Front-end > JS Tutorial > js determine file type and control form submission sample code_javascript skills

js determine file type and control form submission sample code_javascript skills

WBOY
Release: 2016-05-16 17:15:13
Original
1066 people have browsed it

The following code implements control form submission

Copy code The code is as follows:

function shangchuan() {

var filepath = document.getElementById("file").value;
alert(filepath);
if(filepath==""){
alert("Please choose to upload file! ");
document.getElementById("file").disabled=true;

}
var extname=filepath.substr(filepath.length-3, filepath.length);
alert("extname::" extname);
//var extname = filepath.substring(filepath.lastIndexOf(".") 1,filepath.length);
// extname = extname.toLowerCase ();//Handling case
if(extname!= "bmp" && extname!= "jpg" && extname!= "gif"){
alert("Only bmp, jpg, gif can be uploaded Format pictures! ");

document.getElementById("file").disabled=true;
}
else{
document.getElementById("file").disabled=false ;
}

}

Copy code The code is as follows:


< ;/td>


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template