//use === or == for condition checking in javascript./
if(document.getElementById('name').value === ""){
alert("enter something valid");
return false;
}
let student = {
name: 'Jack',
age: 24
}
const handler = {
// get the object key and value
get(obj, prop) {
// check condition
if (prop == 'name') {
return obj[prop];
} else {
return 'Not allowed';
}
}
}
const proxy = new Proxy(student, handler);
console.log(proxy.name); // Jack
console.log(proxy.age); // Not allowed
javascript form validation
let input_value = document.forms["myForm"]["myInputField"].value;
if(input_value == undefined || input_value.trim() == "") {
console.log("InputName is required")
}