Layui判断两个值相加等于100

132 阅读1分钟

js

form.on("submit(editone)", function(data) {
		var one = data.field.nottake;
		var two = data.field.yestake;
		var three = Number(Number(one.replace(/,/g, "")).toFixed(2)*1 +  Number(two.replace(/,/g,"")).toFixed(2)*1);
		console.log(three);
		if(three != 100){
			layer.msg("两个值相加必须是100")
		}
		if(three==100){
			$.ajax($url+'jxgl/S0009F0002',{
				data:{
					level:data.field.yestake,
					notLevel:data.field.nottake
				},
				dataType:'json',
				type:'post',
				timeout:10000,
				success:function(data){
					if (data.result = 200) {
						layer.msg('修改成功', {
							icon: 1,
							time: 2000
						}, function() {
							
						});
					
					} else {
						layer.msg(data.result)
					}
				},
				error:function(xhr,type,errorThrown){
					
				}
			});
		}
		return false;
	});