boolean-uk / team-dev-client-ex-2410-team3

0 stars 0 forks source link

Fix User Registration Email validation not showing all error/help messages #64

Open FredrikEH opened 2 hours ago

FredrikEH commented 2 hours ago
// \src\components\form\textInput\index.js

  ...
  pattern = null,
  patternDescription = null,
  minLength = 0,
  maxLength = 50,
  isLocked = false
}) => {
  ...
  const emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}$/;   // <-- Change this
  ...
// \src\components\form\textInput\index.js

} else if (type === 'email') {
    return (
      <div className="inputwrapper">
        {label && <label htmlFor={name}>{label}</label>}
        <input
          type={type}
          name={name}
          value={value}
          onChange={handleChange}
          pattern={emailPattern}
          className={icon && 'input-has-icon'}   // <-- Fix this
        />
        {icon && <span className="input-icon">{icon}</span>}
        {error && <span className="error-message">{error}</span>}   // <-- Check if something is missing for this to work
      </div>
    );
  }
amos1969 commented 2 hours ago

Approved