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
form validation in react
Search
yiminghe
March 19, 2015
Technology
4
540
form validation in react
do form validation using react
yiminghe
March 19, 2015
Tweet
Share
More Decks by yiminghe
See All by yiminghe
小程序终端技术架构
yiminghe
0
180
支付宝小程序的开放架构
yiminghe
0
170
gitc2016 react based architecture
yiminghe
1
140
antd at qcon2016
yiminghe
1
200
react-based architecture
yiminghe
2
150
React Ecosystem At Ant Financial
yiminghe
4
2.2k
ant design preview
yiminghe
1
260
react best practice
yiminghe
3
180
react at alipay
yiminghe
43
4.3k
Other Decks in Technology
See All in Technology
PostgreSQL Log File Mastery: Optimizing Database Performance Through Advanced Log Analysis
shiviyer007
PRO
1
150
MCPを理解する
yudai00
12
9.1k
もう難しくない!誰でもカンタンDocker入門 〜30分であなたのPCにアプリを立ち上げる〜
devops_vtj
0
180
AIコーディングの最前線 〜活用のコツと課題〜
pharma_x_tech
4
2.9k
DjangoCon Europe 2025 Keynote - Django for Data Science
wsvincent
0
430
AndroidアプリエンジニアもMCPを触ろう
kgmyshin
2
570
10ヶ月かけてstyled-components v4からv5にアップデートした話
uhyo
5
450
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
2
450
地味にいろいろあった! 2025春のAmazon Bedrockアップデートおさらい
minorun365
PRO
2
550
クラウドネイティブ環境の脅威モデリング
kyohmizu
1
290
OpenLane-V2ベンチマークと代表的な手法
kzykmyzw
0
150
3D生成AIのための画像生成
kosukeito
2
580
Featured
See All Featured
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
5
550
Building Better People: How to give real-time feedback that sticks.
wjessup
367
19k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
179
53k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.6k
4 Signs Your Business is Dying
shpigford
183
22k
Statistics for Hackers
jakevdp
798
220k
RailsConf 2023
tenderlove
30
1.1k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
41
2.3k
Build your cross-platform service in a week with App Engine
jlugia
230
18k
Embracing the Ebb and Flow
colly
85
4.7k
Designing for Performance
lara
608
69k
Unsuck your backbone
ammeep
671
57k
Transcript
Form Valida+on In React yiminghe@gmail.com
form • Tradi+onal way • Library way
• React way – rc-‐form-‐valida+on
Tradi+onal way
Problems • Maintenance – Script and html is separated
– A lot of duplica+on – Hard to reuse code – …
Library way • hFp://jqueryvalida+on.org/documenta+on/
Library way • But you s+ll need to get data
when submit! • hFps://api.jquery.com/serialize/
Problems Customiza/on! Invasion!
In Short
DOM Driven
React Way DATA
Driven
Introduce • rc-‐form-‐valida+on • hFps://github.com/react-‐component/form-‐ valida+on
in general
Step by step -‐1 • Valida+on.FieldMixin – handleValidate – setField
Step by step -‐2 • Declare data model – formData:
field value geFer and seFer – Status: field status (errors,valida+ng…)
Step by step -‐3 • Just render html by data
model and valida+on rules – handleValidate provided by mixins – Declare rules in Validator – Wrap input by Validator and Valida+on
Step by step -‐4 • Validate on submit and get
data – Call validate method – Just get data from data model (two-‐way binding)
Advanced usage • Asynchronous valida+on • Validate custom
component
Asynchronous valida+on • Use validator func+on
Validate custom component • Validate custom component which supports
onChange props, such as rc-‐calendar:
What’s next • Isomorphic Valida+on – hFps://github.com/yiminghe/async-‐validator • rc-‐form-‐valida/on
depends on async-‐validator • async-‐validator can be run at nodejs! Let’s share some valida/on rules!
Try hFp://react-‐component.github.io/form-‐ valida+on/build/examples/form.html