Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Making Sure Your Forms Don't Suck
Search
Damian Nicholson
October 23, 2017
Technology
230
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Making Sure Your Forms Don't Suck
Damian Nicholson
October 23, 2017
More Decks by Damian Nicholson
See All by Damian Nicholson
Designing form validation the right way
damian
0
330
Chrome DevTools tips and tricks
damian
0
190
Writing testable, scalable, maintainable rock-solid JavaScript
damian
5
1.6k
Ten Things You Should Know About Jasmine
damian
2
1.1k
Other Decks in Technology
See All in Technology
Bet AI Day 2026丨How We Bet AI: AIとともに働く場をつくる
layerx
PRO
2
2.8k
From Vanilla Kubernetes to a Batteries-Included Platform: Developer Experience at 1,300+ Clusters
yosshi_
0
620
Multica × 長期記憶:40個のミニプロジェクト管理
eiei114
1
200
Webとヘルスデータ
yukukotani
1
200
AIとペアプロを始める。人とのペアプロをやめる。ペアプロの良さを改めて知る。もっと好きになった。 / Rediscovering Pair Programming
honyanya
1
280
WAF 運用改善の承認サイクル/SRE_BizReach_MIXI_1
visional_engineering_and_design
1
360
設計の世代交代を乗り越える、14年続くAndroidアプリの開発戦略
sansantech
PRO
1
150
Beyond the Hype: Practical AI for Your Oracle Database with MCP
thatjeffsmith
1
280
AndroidでHDRメディアを「壊さずに」扱う
chigichan24
0
420
Adaptive Warehouse を今すぐ導入すべき理由と迷ったときの判断基準
__allllllllez__
0
100
synctest時代のhttptest Go 1.27で変わるHTTPサーバテストの裏側 / go conference2026 synctest and httptest
budougumi0617
0
120
OpenTelemetry eBPF Instrumentationの舞台裏 / Behind the Scenes of OpenTelemetry eBPF Instrumentation
ymotongpoo
1
150
Featured
See All Featured
What does AI have to do with Human Rights?
axbom
PRO
1
2.4k
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
1
720
First, design no harm
axbom
PRO
2
1.3k
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
530
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
1
890
The Invisible Side of Design
smashingmag
301
52k
Darren the Foodie - Storyboard
khoart
PRO
3
3.9k
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
570
The browser strikes back
jonoalderson
0
1.6k
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
120
120k
The Power of CSS Pseudo Elements
geoffreycrofte
82
6.5k
Leo the Paperboy
mayatellez
8
2.2k
Transcript
MAKING SURE YOUR FORMS DON'T SUCK @damian
None
None
None
ACCURATE FASTER CONFIDENT SATISFIED https://alistapart.com/article/inline-validation-in-web-forms
https://baymard.com/blog/inline-form-validation E-Commerce sites containing client side validation 40% 60%
https://baymard.com/blog/inline-form-validation E-Commerce sites containing client side validation 12% 40% 48%
THIS LEADS ME TO BELIEVE IT'S PURELY AN IMPLEMENTATION ISSUE
None
None
None
None
WHY IS IT SO HARD TO DO RIGHT?
BUILT TO BE UNRELIABLE
BUILT TO COMPLEMENT SERVER SIDE VALIDATION
ALIGN* AND SYNCHRONISE VALIDATIONS DECLARED ON THE SERVER
RECONCILE SERVER GENERATED VALIDATIONS WITH THOSE ON THE CLIENT
onKeypress - onChange - onBlur RECONCILE ERRORS MANIFESTED ACROSS DIFFERENT
EVENT PHASES
CONDITIONAL VALIDATIONS DEPENDANT ON OTHER FIELD VALUES
ASYNCHRONOUS VALIDATION
HOW DO WE FIX IT?
JUST BEING AWARE THAT SERVER SIDE VALIDATIONS EXIST
RECONCILE ERRORS MANIFESTED ACROSS DIFFERENT EVENT PHASES onKeypress - onChange
- onBlur
onKeypress - onChange - onBlur RECONCILE ERRORS MANIFESTED ACROSS DIFFERENT
EVENT PHASES
REACT CONCEPT OF INTERNAL STATE MANAGEMENT MAKES MORE SENSE AND
IS EASIER TO MANAGE
const fieldAlias = 'userLogin'; this.setState({ [fieldAlias]: { ...this.state[fieldAlias], value: changeFn('
[email protected]
'),
touched: true, } }, () => { Promise.all(validations.map((fn) => { return fn(this.state.values, this.serverErrors(), fieldAlias, 'onChange'); })) .then(() => { this.setValid() }) .catch((errors) => { this.setInvalid(errors) }); });
REMOVE 1 to 1 MAPPING BETWEEN FIELD VALUES AND VALIDATIONS
const validationFn = (values, serverErrors = {}, fieldUpdated, eventPhase) {
return new Promise((resolve, reject) => { const errors = {}; if (!values.userLogin) { errors.userLogin = 'Please enter your email address'; } Object.assign(errors, serverErrors); if (Object.keys(errors).length === 0) { return resolve(errors); } return reject(errors); }); }; CONDITIONAL VALIDATIONS DEPENDANT ON OTHER FIELDS
const SignInForm = ({ ...props }) => { const {
handleChange, handleBlur, form, method, fields, ...other } = props; const { userLogin, password } = form; return ( <form method={method} action="POST" {...other}> <input type="text" data-alias="userLogin" onChange={handleChange} onBlur={handleBlur} value={userLogin.value} /> {userLogin.touched && userLogin.errors.length > 0 && <span>{userLogin.errors}</span> } ... <button>Sign in</button> </form> ); }; export default conferizeForm(SignInForm, validationFn);
Consolidated event handling - either onChange or onBlur Conditional validations
Sync and async validations declared and resolved using Promise API Composable validations Developers own their form and it's fields Synchronising server and client side validations
MAKES USERS HAPPY BUT ONLY IF DONE RIGHT
REACT MAKES THAT A LOT EASIER
THE END