Instance
The code is as follows |
Copy Code |
<script language= "JavaScript" > function Mysubmit (theform) { if (theform.big.value== "") { Alert ("Click the browse button, select the JPG or GIF file you want to upload!") Theform.big.focus; return (false); } Else { Str= Theform.big.value; Strs=str.tolowercase (); Lens=strs.length; Extname=strs.substring (Lens-4,lens); if (extname!= ". jpg" && extname!= ". gif") { Alert ("Please select JPG or gif file!"); return (false); } } return (true); } </script> <form enctype= "Multipart/form-data" action= "zsupload_save.asp" Method=post onsubmit= "return Mysubmit (This)" > <TR><TD align= "Left" >
<input type= "file" Name= "Big" size= "class=" "Inputh" > <input type= "hidden" name= "filepath" value= "upload_img" class= "Inputh" > <input type= "hidden" name= "hid" value= "<%=myhid%>" > <input type= "Submit" name= "Upload" value= "upload" class= "Inputh" > maximum <font color= "#FF0000" >12</ Font> Zhang
</td> </tr></form> |
If you want to upload, you can only choose a picture of the Chinese name (can you use the Toascii method?) ), the first two days of the "JavaScript development King" is just the Unicode range in Chinese, is the following:
Core Code
The code is as follows |
Copy Code |
/[u4e00-u9fa5uf900-ufa2d]/ |
Write a simple test that will replace all Chinese with "Oh".
The code is as follows |
Copy Code |
<script type= "Text/javascript" > var str = "have Chinese? and 中文版." var reg =/[u4e00-u9fa5uf900-ufa2d]/ig; str = str.replace (reg, ' oh '); document.write (str); </script> |
So we just need to do the Chinese verification before mysubmit submission.