add form validation
This commit is contained in:
@@ -14,6 +14,9 @@ export default function Nominations() {
|
||||
const [songURL, setSongURL] = useState("");
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const [message, setMessage] = useState("");
|
||||
const isSpotifyURL =
|
||||
/^https:\/\/open\.spotify\.com\/track\/[a-zA-Z0-9]{22}/.test(songURL);
|
||||
|
||||
async function nominate(spotifyLink: string) {
|
||||
try {
|
||||
setIsAnimate(false);
|
||||
@@ -54,7 +57,7 @@ export default function Nominations() {
|
||||
<button
|
||||
className="w-full rounded bg-blue-500 px-4 py-2 text-center font-bold text-white hover:bg-blue-400 disabled:cursor-not-allowed disabled:bg-gray-500"
|
||||
type="submit"
|
||||
disabled={isLoading || !songURL.trim()}
|
||||
disabled={isLoading || !songURL.trim() || !isSpotifyURL}
|
||||
onClick={async (e) => {
|
||||
e.preventDefault();
|
||||
if (!songURL.trim()) return;
|
||||
|
||||
Reference in New Issue
Block a user