0

用户在 FormControl 中输入文本字符串,我想将其重新修剪并小写。

handleSubmit(event) {
    event.preventDefault();

    console.log("submitted: "+ this.vehicleReg.value.trim().toLowerCase());
    this.refs.vehicleReg.value=this.vehicleReg.value.trim().toLowerCase();
}

render() {
    return(
        <form className="user-data" onSubmit={this.handleSubmit.bind(this)}>
            <FormGroup label="Data">
                <FormControl
                    inputRef={(input) => this.vehicleReg = input} type="text"
                    placeholder="Reg Number"
4

1 回答 1

0

将名称属性添加到您的FormControl然后执行以下操作handleSubmit

document.querySelector('[name="regNum"]').value = document.querySelector('[name="regNum"]').value.trim().toLowerCase();
于 2017-01-09T19:50:09.243 回答