Last active
December 10, 2021 03:53
-
-
Save Mulli/7425a153c59bb5ac618a88c3e4afbd6b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Add the following right after the Form widget as HTML widget */ | |
/* Assume name field with id="name" and email field with id="email" */ | |
<script> | |
jq2 = jQuery.noConflict(); | |
jq2(function( $ ) { | |
$(":submit").click(function(event){ | |
let name = $("#form-field-name").val(); | |
let email = $("#form-field-email").val(); | |
// alert('submit clicked name='+name + " email="+email+"<<"); | |
if ((name === undefined || name === "") && $('#name-err').length === 0) | |
$("#form-field-name").after( "<span style='color:red' aria-label='alert' id='name-err'>Name field is required</span>"); | |
if ((email === undefined || email === "") && $('#email-err').length === 0) | |
$("#form-field-email").after( "<span style='color:red' aria-label='alert' id='email-err'>Email field is required</span>"); | |
//$("#form-field-email").css({"backgroundColor": "red", "color": "blue"}); | |
//$("#form-field-name").css({"border": "5px solid red"}); | |
//event.preventDefault(); | |
}); | |
$("#form-field-name").change(function() { | |
$("#name-err").remove(); | |
}); | |
$("#form-field-email").change(function() { | |
$("#email-err").remove(); | |
}); | |
}); | |
</script> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Notes: