title: Remove white spaces from both ends of a string inside a form - React
body: <p>I have a simple form that receives the first name and last name, and I need to remove the whitespaces in the beginning and end of the string. I can do this with the <code>.trim()</code> method, but because is a form, it doesn't let me write a name that has two words, such as Ana Maria, because it doesn't let me press the space key at the end of a word. How can I remove white spaces from both sides of a string but still let me press space and write more than one word?</p>
  
  <p><a href="https://i.stack.imgur.com/tvCSm.png" rel="noreferrer"><img src="https://i.stack.imgur.com/tvCSm.png" alt="enter image description here"></a></p>
  
  <p>This is the component: </p>
  
  <pre><code>export default function ScheduleInput(
    { label, required, onChange, value, ...extraProps },
  ) {
    return (
      &lt;div className="item_container"&gt;
        {label}:
        {required &amp;&amp;
          &lt;span style={{ color: 'red' }}&gt; *&lt;/span&gt;
        }
        &lt;br /&gt;
        &lt;input
          type="text"
          onChange={onChange}
          value={value.trim()}
          {...extraProps}
        /&gt;
      &lt;/div&gt;
    );
  }
  </code></pre>