diff --git a/public/react/src/modules/courses/boards/AddDirModal.js b/public/react/src/modules/courses/boards/AddDirModal.js index 89ff6dfeb..e91ab278e 100644 --- a/public/react/src/modules/courses/boards/AddDirModal.js +++ b/public/react/src/modules/courses/boards/AddDirModal.js @@ -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( + + {errorMsg && {errorMsg}} {/* {this.state.NavmodalValuetype===true? {this.state.NavmodalValues}