0

Hi if my criteria gets satisfied i need to set the value as blank in input field in the Lightning Web Component.

please help me out for this.

Html:- {dueDate}

  • You need to set the date input as null in your if condition in javascript. – Aakriti.G Jul 15 at 14:50
  • How can i do in javascript?? – Tisca Jul 15 at 14:52
  • Just do this.startDate = ''. – rahul gawale Jul 15 at 14:57
  • this is working for only one time if user select the wrong value the it is getting populated – Tisca Jul 15 at 15:01
0

In your javascript file, you need to set the date as null in your if condition. Refer this:-

if (fieldName === 'start-date') {
    let checkstartdate = evt.target.value;
    console.log("checkenddate == "+new Date(checkstartdate));
    if((????Condition) {
    this.startDate = null; <ADD_THIS_LINE>
    ///**Here on UI I want to set the Start date field as Blank**///
    this.template.querySelector('start-date').reset();
    this.showToast("lllllll");
    this.dateValidity = false;
}
else {
      this.startDate = evt.target.value;
}
| improve this answer | |
  • Thanks @Akriti For the fist time this is working fine but for the next time if user again select the wrong date it is getting populated.. – Tisca Jul 15 at 15:07
  • Please check your condition is working properly. The If condition (Line no 4 in js). Try to use console.log to check if it is going inside your if condition. – Aakriti.G Jul 15 at 15:10
  • I checked Toast is getting called everytime but Field is getting blank for first time only. – Tisca Jul 15 at 17:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.