The out-of-focus event of calling input in the submit function of Mini Program's form will report an error. Ask for guidance.

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


if you call the function directly, if the this cannot be passed, you can't get the user name and password.
the correct way is to bind the value of the component to the name and password in data
check the name and password, in the data so that no matter where the function is called, it can run normally

.
Menu