if string contain white space alert should be unsuccessful and if string contain no white space alert should be successful
import React from “react”;
export default function DropDown() {
let i=document.getElementById("input")?.value;
const submit=()=>{
var whiteSpaceExp = /^s+$/g;
if (whiteSpaceExp.test(i))
{
alert('unsuccess');
}
else
{
alert('success');
}
}
return (
<>
<form>
<input type="text" id="input" autoComplete="off" />
<button onClick={submit}> click </button>
</form>
</>
);
}