From c271777f2d5ee1902b97973debd66fa3ca8f7810 Mon Sep 17 00:00:00 2001 From: soujanya hazra Date: Wed, 9 Mar 2022 00:47:10 +0530 Subject: [PATCH] get-in-touch validation improved --- assets/js/app.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/assets/js/app.js b/assets/js/app.js index 45ecf8400..4e5acd4b2 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -1,5 +1,10 @@ "use strict"; +// Sweet Alert CDN through JS +let script = document.createElement("script"); +script.type = 'text/javascript'; +script.src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"; +document.body.appendChild(script); // Header @@ -444,17 +449,17 @@ $(function submitAnimation() { // Check if the name field is empty or contains a number if (name.value == "" || (/\d/.test(name.value))) { - alert('Please enter a valid name'); + swal("Error !","Please enter a valid name !","error"); return; } // Check if the email field is empty or email is not valid ex: test@@email.com else if (emailAdress.value == "" || !(emailPattern.test(emailAdress.value))) { - alert('Please enter a valid email'); + swal("Error !","Please enter a valid email !","error"); return; } // Check if the message field is empty else if (text.value == "") { - alert('Please enter your message'); + swal("Error !","Please enter a valid message !","error"); return; } else {