图片上传
if(document.getElementById("radio1").checked==true&&document.getElementById("fileName").value=="")
{
alert("注意:你选择了上传图片,但是没有加载!");
return false;
}
var fileName=" "+document.form1.voucherFile.value;
fileName=fileName.substring(fileName.length-4,fileName.length);
if((document.getElementById("radio1").checked==true)&&(document.getElementById("fileName").value!="")&&(fileName.toUpperCase().indexOf(".JPG")==-1)&&(fileName.toUpperCase().indexOf(".BMP")==-1)&&(fileName.toUpperCase().indexOf(".GIF")==-1))
{
alert("请上传以JPG,BMP,GIF为结尾的文件!!");
salebusinessform.voucherFile.focus();
return false;
}
<!--Start-->
//禁用鼠标右键
tmp=navigator.appVersion.toString();
IE=parseFloat(tmp.substring(tmp.indexOf("MSIE")+4,tmp.length));
function NC_rightclick(e)
{
if(e.button==2 || (e.button==0 && e.type=="contextmenu"))
{
document.getElementById('just_hide_it').style.left=e.clientX-14;
document.getElementById('just_hide_it').style.top=e.clientY-14;
return false;
}
}
if(IE)
document.οncοntextmenu=Function("return false;");
else
{
document.write('<div id="just_hide_it" style="z-index:-1;position:absolute;left:100;top:0;overflow:scroll;width:28;height:28;"></div>');
document.οncοntextmenu=NC_rightclick;
document.οnmοusedοwn=NC_rightclick;
}
//判断日期是否有效
function isDate(datestr)
{
var lthdatestr
if (datestr != "")
lthdatestr= datestr.length ;
else
lthdatestr=0;
var tmpy="";
var tmpm="";
var tmpd="";
var status;
status=0;
if ( lthdatestr== 0)
return false
for (i=0;i<lthdatestr;i++)
{
if (datestr.charAt(i)== '-')
{
status++;
}
if (status>2)
{
return false;
}
if ((status==0) && (datestr.charAt(i)!='-'))
{
tmpy=tmpy+datestr.charAt(i)
}
if ((status==1) && (datestr.charAt(i)!='-'))
{
tmpm=tmpm+datestr.charAt(i)
}
if ((status==2) && (datestr.charAt(i)!='-'))
{
tmpd=tmpd+datestr.charAt(i)
}
}
year = new String (tmpy);
month = new String (tmpm);
day = new String (tmpd)
if ((tmpy.length!=4) || (tmpm.length>2) || (tmpd.length>2))
{
return false;
}
if (!((1<=month) && (12>=month) && (31>=day) && (1<=day)) )
{
return false;
}
if (!((year % 4)==0) && (month==2) && (day==29))
{
return false;
}
if ((month<=7) && ((month % 2)==0) && (day>=31))
{
return false;
}
if ((month>=8) && ((month % 2)==1) && (day>=31))
{
return false;
}
if ((month==2) && (day==30))
{
return false;
}
return true;
}
//判断是否为空函数
function isEmpty(s) {
return ((s == null) || (s.length == 0));
}
//检测非法字符函数
function isWhitespace (s) {
var whitespace = " /t/n/r%<>///<>&*_?[]{}/'/":; ";
if (isEmpty(s)) return true;
var i;
for (i = 0; i < s.length; i++)
{
var c = s.charAt(i);
if (whitespace.indexOf(c) != -1)
continue;
else
return false;
}
return true;
}
//验证Email函数
function isEmail(s) {
// there must be >= 1 character before @, so we
// start looking at character position 1
// (i.e. second character)
var i = 1;
var sLength = s.length;
// look for @
while ((i < sLength) && (s.charAt(i) != "@"))
{
i++;
}
if ((i >= sLength) || (s.charAt(i) != "@")) return false;
else i += 2;
// look for .
while ((i < sLength) && (s.charAt(i) != "."))
{
i++;
}
// there must be at least one character after the .
if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false;
else return true;
}
//判断数字函数
function isNumber(s)
{
var digits = "0123456789";
var i = 0;
var sLength = s.length;
while ((i < sLength))
{
var c = s.charAt(i);
if (digits.indexOf(c) == -1) return false;
i++;
}
return true;
}
//得到金额的长度
function doublelength(theField,n,s)
{
var ss=theField.value;
var num=ss.length;
if(ss<0){
return 0;;
}
if(ss.indexOf(".")==-1){
num=num+3;
}
if(ss.indexOf(".")!=-1){
if(ss.substring(ss.indexOf("."),ss.length).length<3){
num=ss.indexOf(".")+3;
}
}
if(num>n){
return warnInvalid (theField, s);
}
return true;
}
//判断是否是金额
function isDouble(theField,s)
{
var ss=theField.value;
if(ss<0){
return warnInvalid (theField, s);
}
if(isNaN(parseFloat(ss))){
return warnInvalid (theField, s);
}
else{
if(parseFloat(ss)!=ss){
return warnInvalid (theField, s);
}
}
return true;
}
/*function isDouble(theField,s)
{
var ss=theField.value;
var digits = "0123456789.";
var i = 0;
var j = 0;
var sLength = ss.length;
if (!isNumber(theField.value))
{
while ((i < sLength))
{
var c = ss.charAt(i);
if (digits.indexOf(c) == -1)
return warnInvalid (theField, s);
else{
if (c=='.'){
j++;
}
if(j>2&&ss.substring(ss.lastIndexOf('.'),ss.length).length!=2&&ss.lastIndexOf('.')==0){
return warnInvalid (theField, s);
}
}
i++;
}
}
return true;
}*/
//提示空字符
function warnEmpty (theField, s)
{ alert(s);
theField.focus();
return false;
}
//提示无效输入
function warnInvalid (theField, s)
{ alert(s);
theField.focus();
theField.select();
return false;
}
//检测非法字符
function checkString (theField,s)
{ // Make sure the field exists before completing the test
if (theField == null) return true;
if (isWhitespace(theField.value))
return warnEmpty (theField, s);
else return true;
}
//检测日期
function checkDate(theField,s)
{
if (!isDate(theField.value))
return warnInvalid (theField, s);
else return true;
}
//检测Email
function checkEmail (theField,s)
{
if (!isEmail(theField.value))
return warnInvalid (theField, s);
else return true;
}
//检测下拉框
function checkSelect(theSelect,s)
{
if (theSelect.options[theSelect.selectedIndex].value != "-1" && theSelect.options[theSelect.selectedIndex].value != "") return true;
else
{
theSelect.focus();
warnEmpty(theSelect,s);
return false;
}
}
//检测是否是数字
function checkNumber (theField,s)
{
if (!isNumber(theField.value)) return false;
if (isWhitespace(theField.value))
return warnEmpty (theField, s);
else return true;
}
//检测邮编函数
function checkzip (theField,s)
{
var ss=theField.value;
var digits = "0123456789";
var i = 0;
var sLength = ss.length;
if(sLength<6)
return warnInvalid (theField, s);
while ((i < sLength))
{
var c = ss.charAt(i);
if (digits.indexOf(c) == -1)
return warnInvalid (theField, s);
i++;
}
return true;
}
//验证区号
function checkArea(theField)
{
if (theField.value.length < 3)
{
alert("请输入区号");
theField.focus();
return false;
}
else return true;
}
//检测电话号码
function checkPhone(theField,s)
{
var ss=theField.value;
var digits = "0123456789- ";
var i = 0;
var sLength = ss.length;
while ((i < sLength))
{
var c = ss.charAt(i);
if (digits.indexOf(c) == -1)
return warnInvalid (theField, s);
i++;
}
c = "--";
if (ss.indexOf(c) != -1)
return warnInvalid (theField, s);
return true;
}
//检测密码
function checkPassWord(theField)
{
if (theField.value.length < 4)
{
alert("密码长度小于4");
theField.focus();
return false;
}
else return true;
}
//比较两次输入的密码
function comparePWD(theField1,theField2,str){
if(theField1.value!=theField2.value){
alert(str);
theField1.value="";
theField2.value="";
theField1.focus();
return false;
}
else return true;
}
//验证复选框
function checkBox(form,str)
{
for (var i=0;i<form.elements.length; i++){
var e = form.elements[i];
if (e.value == "radio"&&e.checked)
return true;
}
alert(str);
return false;
}
//检测汉字
function CheckIString(stringObj)
{
var tempString=stringObj;
if(stringObj==null)return false;
if(stringObj.length==0)return false;
for(;tempString.indexOf(" ")!=-1;tempString=tempString.replace(" ","")){}
//alert(tempString.length);
if(tempString.length==0)return false;
var errorString=new Array("%","/","