名称不能超过20个字

dev_forum
hjm 6 years ago
parent 328fd86b55
commit 41edd7f5e6

@ -22,6 +22,15 @@ class AddDirModal extends Component{
let coursesId = this.props.match.params.coursesId;
const url = `/courses/${coursesId}/boards.json`
let { inputValue } = this.state;
if (!inputValue) {
this.setState({ errorMsg: '名称不能为空'})
return;
}
if (inputValue.length > 20) {
this.setState({ errorMsg: '名称不能超过20个字'})
return;
}
this.setState({ errorMsg: ''})
axios.post(url,{
name: inputValue
@ -36,10 +45,10 @@ class AddDirModal extends Component{
})
}
onCancel = () => {
this.setState({ visible: false, inputValue: '' })
this.setState({ visible: false, inputValue: '', errorMsg: '' })
}
render(){
let { inputValue, visible } = this.state;
let { inputValue, visible, errorMsg } = this.state;
const { title } = this.props;
return(
<Modal
@ -61,6 +70,8 @@ class AddDirModal extends Component{
onInput={this.onInput}
/>
</div>
{errorMsg && <span style={{color: 'red'}}>{errorMsg}</span>}
{/* {this.state.NavmodalValuetype===true?<span className={"color-red"}>
{this.state.NavmodalValues}

Loading…
Cancel
Save