Meteor React-Bootstrap: how to set value to FormControl

352 views Asked by At

Users enter text string into FormControl, I want to put it back trimmed and lower-cased.

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"
1

There are 1 answers

0
416serg On

Add a name attribute to your FormControl then do the following in handleSubmit

document.querySelector('[name="regNum"]').value = document.querySelector('[name="regNum"]').value.trim().toLowerCase();