WeChat Mini Programs does form form submission. I call each input-bound out-of-focus event in the submit function of the form component, and verify each input data before submitting the form, but find that calling the out-of-focus event directly will report an error. The specific code is as follows:
<form bindsubmit="submit">
<input placeholder="" bindblur="checkName"/>
<input placeholder="" bindblur="checkPassword"/>
<button form-type="submit"></button>
</form>
Page({
data: {
name: "",
password: ""
},
checkName:function (e) {
//
console.log(e.detail.value);
if(){
return true;
}
return false;
},
checkPassword:function(e) {
//
console.log(e.detail.value);
if(){
return true;
}
return false;
},
submit:function (e) {
if (!this.checkName()) return
if (!this.checkPassword()) return
}
})
error: Cannot read property "detail" of undefined;at pages/index/index page checkName function
TypeError: Cannot read property" detail" of undefined
if you do not call those out-of-focus functions in submit, the normal input out-of-focus can print e.detail.value, but why do you report an error when adjusted