function User(fullname,username,email,password,postcode,age,aggrement){
this.fullname=fullname,
this.username=username,
this.email=email,
this.password=password,
this.postcode=postcode,
this.age=age,
this.aggrement=aggrement
}
Object.defineProperty(User.prototype,"fullname",{
set: function(value){
if(value.length<8){
this.fullname="invalid"
}else{
this.fullname=value
}
}
})
function display(){
event.preventDefault()
const fullname=document.getElementById("fname").value
const username=document.getElementById("username").value
const email=document.getElementById("email").value
const password=document.getElementById("password").value
const postcode=document.getElementById("postCode").value
const age=document.getElementsByName("age")[0]
const aggrement=false
let firstName=fullname.split(" ")[0]
firstName= new User(fullname,username,email,password,postcode,age,aggrement)
console.log(firstName)
}
I would like to get data from the form and create an object with that form while creating the object I would like to make some rules, such as the length of fullname should be longer than 8 etc. Can anyone tell me how i can use getters and setter ton this project?