Calculation error in ERP Next web form

Hi,

Please help me with custom script(Client script) for webform:

I created a doctype with the following fields:

  • First Name

  • Last name

  • From date

  • Price

  • Quantity

  • Total.

I make First Name is mandatory.
Calculate the Total as follows:

frappe.web_form.on(‘quantity’, (field, value) => {
let data = frappe.web_form.get_values();
var a = data.price;
var b = data.quantity;
var c = a*b;
frappe.web_form.set_value(‘total_amount’, [c]);
});

It works fine but my problem is with out entering the First name I entered Price and Quantity but it does not update to the Total field. it shows the like below:

But I did not submit the form. I need to pop-up only when submit.
first I need to perform the calculation.