Skip to content

Commit

Permalink
feat: set_value
Browse files Browse the repository at this point in the history
  • Loading branch information
GaturaN committed Aug 28, 2024
1 parent 340a1c9 commit cc00019
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions smartbill/smartbill/doctype/customer/customer.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@ frappe.ui.form.on("Customer", {
let id = frm.doc.national_id;
// check if it is not a number
if (isNaN(id)) {
frm.set_value("national_id", "");
frappe.throw("National ID is not valid");
}
// check if length is correct
if (id.length !== 8) {
frm.set_value("national_id", "");
frappe.throw("National ID is not valid");
}
}
Expand All @@ -47,18 +49,17 @@ frappe.ui.form.on("Customer", {
frm.doc.passport_number.length < 6 ||
frm.doc.passport_number.length > 9
) {
frm.set_value("passport_number", "");
frappe.throw("Passport number is not valid");
}
}
},

email(frm) {
// check if email is valid
if (frm.doc.email) {
if (!frm.doc.email.includes("@")) {
frappe.msgprint("Email is not valid");
if (!frm.doc.email.includes("@")) {
frm.set_value("email","");
frappe.throw("Email is not valid");
}
}
}
},

date_of_birth(frm) {
Expand Down Expand Up @@ -93,7 +94,9 @@ frappe.ui.form.on("Customer", {
// Check if age > 18
if (frm.doc.age) {
if (parseInt(frm.doc.age) < 18) {
frm.set_value("date_of_birth", "");
frappe.throw("Must be 18 or older");

}
}
},
Expand Down

0 comments on commit cc00019

Please sign in to comment.