DEV Community

Discussion on: Form validation using javascript

 
jonrandy profile image
Jon Randy 🎖️

All the in-built stuff can be called with JS. You just need to augment it a little for cases like this - not re-invent the wheel

Thread Thread
 
rkallan profile image
RRKallan

When a user use inspect element and change the pattern or and the type the build in validation would result in a false isValid

Thread Thread
 
jonrandy profile image
Jon Randy 🎖️ • Edited

Similarly, any JS-only validation can be bypassed (breakpoints, changing values etc.)

Far too many sites these days forget this. I've lost count of the number of forms I've 'fooled' into letting me continue as all the validation is done client-side. I've even seen 'server-side' validation fail as the result of a server-side check whose result was being checked on the client-side - something like this:

const formIsValid = validateFormServerSide()

// make a breakpoint here, change formIsValid to true ...
// Voila! 'server-side' validation bypassed

if (formIsValid) {
  // Do stuff
}
Enter fullscreen mode Exit fullscreen mode
Thread Thread
 
rkallan profile image
RRKallan

True submitting a form needs also to be validate on server side.