Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <style>
- .adoric-custom-error {
- width: 200px;
- height: 40px;
- font-size: 11px;
- color: red;
- opacity: 1;
- position: absolute;
- top: 25px;
- left: 15px;
- display: none;
- z-index: 100;
- }
- @media screen and (max-width: 800px) {
- .adoric-custom-error {
- top: 30px;
- font-size: 10px;
- }
- }
- @media screen and (max-width: 450px) {
- .adoric-custom-error {
- top: 25px;
- font-size: 9px;
- }
- }
- </style>
- <script>
- (function() {
- const errorMessage1 = 'Please, do not use +';
- const errorMessage2 = 'Please, do not use @ after .';
- const emailField = document.querySelector('.' + self.identifier + ' [tabindex] INPUT[name="email"]');
- const submitButton = document.querySelector('.' + self.identifier + ' [tabindex] INPUT[name="submit"]');
- const current = document.querySelector('.' + self.identifier + ' [tabindex]');
- const errorBlock = document.createElement('div');
- errorBlock.className = 'adoric-custom-error';
- emailField.after(errorBlock);
- if (emailField) {
- emailField.addEventListener('input', function() {
- setTimeout(function() {
- const emailFieldValue = emailField.value;
- const regexpPlus = /\+/;
- const regexpTest = /\+soda_test/i;
- const regexpMail = /\.@/;
- submitButton.style.pointerEvents = 'auto';
- errorBlock.style.display = 'none';
- if (regexpPlus.test(emailFieldValue)) {
- submitButton.style.pointerEvents = 'none';
- showValidationmessage(errorMessage1);
- if (regexpTest.test(emailFieldValue)) {
- submitButton.style.pointerEvents = 'auto';
- errorBlock.style.display = 'none';
- }
- }
- if (regexpMail.test(emailFieldValue)) {
- submitButton.style.pointerEvents = 'none';
- showValidationmessage(errorMessage2);
- }
- }, 150);
- });
- }
- function showValidationmessage(message) {
- errorBlock.style.display = 'block';
- errorBlock.textContent = message;
- }
- })();
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement