form表单使用ajaxsubmit上传文件,并验证

6 篇文章 0 订阅
在form表单提交时,需要上传图片,在上传前还需要验证表单中的数据是够要求,在表单提交之后,得到一个返回值,并执行一个返回函数。
为了满足要求,使用了jquery.form.js框架,完全能满足要使用的要求,先引入这个插件,可自行百度。
先写出html代码
<form id="pro_change">
	<label>商品名称:</label><input type=text name="proname"id="uptdogPro_name" class="myinput">
	<input type="hidden" name="proid" id="upproid" value="${loginUser.vuid}"/>  
	<label style="padding-left:100px;">商品规格:</label><input type=text name="nature"id="uptdogPro_nature" class="myinput"><br /> <br /> 
	<label>品牌名称:</label><select name="brandid" id="uptdogPro_brname"class="myinput"  style="width:145px;"></select>
	<label style="padding-left:100px;">商品图片:</label><input type=file name="pictrues" id="uptdogPro_pic" multiple="multiple" οnchange="previewMultipleImage(this,'uptpro_pic_show')"><br /> <br /> 
	<label>所属类型:</label><select name="fid" id="uptdogPro_finame"class="myinput" style="width:145px;" onChange="changeER()"></select>
	<label style="padding-left:100px;">所属分类:</label><select name="tid" id="uptdogPro_tpname"class="myinput"></select><br /> <br />
	<label>市 场 价 : </label><input type=text name="promarprice"id="uptdogPro_marpri" class="myinput">
	<label style="padding-left:100px;">波 奇 价 : </label><input type=text name="bqpri"id="uptdogPro_bqpri" class="myinput"><br /> <br /> 
	<label>商品销量:</label><input type=text name="prosales"id="uptdogPro_sales" class="myinput">
	<label style="padding-left:100px;">商品库存:</label><input type=text name="inventory" id="uptdogPro_inven" class="myinput"><br /> <br /> 
	<label>商品状态:</label><select name="status" id="uptdogPro_status"class="myinput"></select><br /> <br />   
	<label style="float:left;">商品介绍:</label><input type=file name="prointros" id="uptdogPro_intro" οnchange="previewMultipleImage(this,'upproinfo_pic_show')"><br /> <br /> 
	<a href="javascript:uptDogProInfo()" class="easyui-linkbutton" data-options="iconCls:'icon-edit'">修改</a>
</form>
再是js代码
function uptDogProInfo(){
	var ajax_option={
		url:"productinfo_changeproducttt.action",//form 的action
		type:"post",  //form 的method方法
		beforeSubmit:checkUppro,  //在表达提交前执行的验证函数
		contentType: "application/x-www-form-urlencoded; charset=utf-8",   //设置编码集
		success:function(data){  //表单提交成功后执行的函数
			alert("执行成功!");
		}
	}
	$('#pro_change').ajaxSubmit(ajax_option);
}


  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值