I'm
  • Creating
  • Learning
  • Building
  • Progressing

JavaScript (Validation)

        
    function validateForm() {
        var firstName = document.getElementById('first-name').value;
        var lastName = document.getElementById('last-name').value;
        var email = document.getElementById('email').value;
        var subject = document.getElementById('subject').value;
        var message = document.getElementById('contact-message').value;
        var errorMessage = document.getElementById('errorMessage');

        // Reset previous error messages and hide the error div
        errorMessage.innerHTML = '';
        errorMessage.style.display = 'none';

        // Check if required fields are empty
        if (firstName.trim() === '') {
            errorMessage.innerHTML += '
First Name is required.
'; } if (lastName.trim() === '') { errorMessage.innerHTML += '
Last Name is required.
'; } if (email.trim() === '') { errorMessage.innerHTML += '
Email is required.
'; } if (message.trim() === '') { errorMessage.innerHTML += '
Message is required.
'; } // Validate email using regex var emailRegex = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; if (!emailRegex.test(email)) { errorMessage.innerHTML += '
Please enter a valid email address.
'; } // If there are error messages, display the error div if (errorMessage.innerHTML !== '') { errorMessage.style.display = 'block'; return false; } // Form submitted successfully return true; }

The provided JavaScript function, validateForm(), serves a critical role in ensuring the integrity of the contact form on your portfolio website.

It verifies that users have entered valid information into the designated fields before permitting form submission.

By meticulously checking for errors such as empty required fields and improperly formatted email addresses, the function maintains the quality of the data received.

Moreover, it communicates with users by presenting alert messages to notify them of any issues encountered during the form submission process, offering a seamless and user-friendly experience.

JavaScript (Typing Effect)

            
    const dynamicText = document.querySelector(".dynamic-txts li span");
    const words = ["Violeta Last", "Creative", "Designer", "Developer"];

    let wordIndex = 0;
    let charIndex = 1;
    let isDeleting = false;

    const typeEffect = () => {
        const currentWord = words[wordIndex];
        const currentChar = currentWord.substring(0, charIndex);
        dynamicText.textContent = currentChar;
        dynamicText.classList.add("stop-blinking");

        if (!isDeleting && charIndex  0) {
            charIndex--;
            setTimeout(typeEffect, 100);

        } else {
            isDeleting = !isDeleting;
            dynamicText.classList.remove("stop-blinking");
            wordIndex = !isDeleting ? (wordIndex + 1) % words.length : wordIndex;
            setTimeout(typeEffect, 1200);
        }
    }

    document.addEventListener("DOMContentLoaded", typeEffect);
            
        

The provided JavaScript code creates an engaging and dynamic text display with a typewriter effect.

By cycling through a predefined array of words, it adds a captivating element to my portfolio, making it more visually appealing and interactive for visitors.

The script simulates the typing and deletion of text characters, creating a fluid and continuous animation that grabs users' attention.

This dynamic presentation showcases my creativity and technical skills as a developer, Overall the typewriter effect contributes to a memorable and engaging user experience, enhancing the overall impact of my portfolio.

Contact Me

leave a message below and I'll get back to you!