forked from Kenshin/simpread
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinclude.jsx
More file actions
50 lines (42 loc) · 1.36 KB
/
include.jsx
File metadata and controls
50 lines (42 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
console.log( "===== simpread option common: Include =====" )
import { verifyHtml } from 'util';
import TextField from 'textfield';
export default class Include extends React.Component {
static defaultProps = {
mode: "",
flag: {},
}
static propType = {
mode : React.PropTypes.oneOf([ "focus", "read" ]),
flag : React.PropTypes.object,
}
state = {
error : ""
};
changeInclude( event ) {
let code = 0;
if ( this.props.mode == "read" && event.target.value.trim() == "" ) {
code = -2;
this.setState({ error : "当前输入不能为空。" });
}
else if ( verifyHtml( event.target.value.trim() )[0] != -1 ) {
this.setState({ error : "" });
} else {
code = -1;
this.setState({ error : "当前输入为非法。" });
}
this.props.changeInclude( event.target.value.trim(), code );
}
render() {
return (
<TextField
multi={ false }
placeholder= "必填,不可为空。"
floatingtext="高亮区域"
value={ this.props.include }
errortext={ this.state.error }
onChange={ evt=>this.changeInclude(evt) }
/>
)
}
}