I'm using EJS for templating in my Node project. I have built a form with over 30 fields. On submit I check for empty and required form fields and return to the form if found empty. I want to save other form fields data entered by the user, so they will not have to re-enter everything from the start. This is what my code looks like and I didn't add all the field names here to save time reading it.
const register = (req, res) => { const firstname = req.body.firstname; const lastname = req.body.lastname; const fullname = req.body.fullname; const nic = req.body.nic; const gender = req.body.gender; const dob = req.body.dob; const age = req.body.age; if (!firstname || !lastname || !nic) return res.redirect('/users/register'); }
I'm very new in coding and stackoverflow, so please help me solving this. Many thanks in advance.... Excuse me for my not good enough english
https://stackoverflow.com/questions/66913317/how-to-check-for-empty-fields-and-return-to-the-form-with-entered-data April 02, 2021 at 09:08AM
没有评论:
发表评论