Commit 74ef6d94 authored by hbcui1984's avatar hbcui1984

云端数据库增加非空判断

parent f78aaa8a
......@@ -91,7 +91,7 @@
<input type="text" class="mui-input-clear" id="col2" placeholder="请输入">
</div>
<div class="mui-input-row">
<label>字段2</label>
<label>字段3</label>
<input type="text" class="mui-input-clear" id="col3" placeholder="请输入">
</div>
</form>
......@@ -106,6 +106,12 @@
</div>
<script type="text/javascript">
function trim(str){ //删除左右两端的空格
   return str.replace(/(^\s*)|(\s*$)/g, "");
   }
var network = false;
var ref = null;
mui.plusReady(function () {
......@@ -150,6 +156,16 @@
if(!ref){
mui.toast("当前网络不给力,请稍后再试");
}else{
var check = true;
mui(".mui-input-group input").each(function () {
if(!this.value||trim(this.value)==""){
var label = this.previousElementSibling;
mui.alert(label.innerText+"不允许为空");
check = false;
return false;
}
});
if(check){
var newRef = ref.push({
"col1": col1.value,
"col2": col2.value,
......@@ -162,9 +178,20 @@
//刷新界面
getList();
}
}
});
document.getElementById("update").addEventListener("tap", function() {
var check = true;
mui(".mui-input-group input").each(function () {
if(!this.value||trim(this.value)==""){
var label = this.previousElementSibling;
mui.alert(label.innerText+"不允许为空");
check = false;
return false;
}
});
if(check){
var newRef = ref.child(document.getElementById("col1").getAttribute("demoid"));
newRef.update({
"col1": col1.value,
......@@ -177,6 +204,7 @@
mui.toast("修改成功~");
//刷新界面
getList();
}
})
document.getElementById("del").addEventListener("tap", function() {
var newRef = ref.child(document.getElementById("col1").getAttribute("demoid"));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment