Bugün stajımda HTML form etiketleri ve bunların JavaScript ile nasıl kontrol edileceği üzerinde çalıştım. Öncelikle basit bir form yapısı oluşturdum. Formun içinde kullanıcı adını girmek için bir input[type="text"] ve formu göndermek için bir submit butonu tanımladım. CSS ile formu ortaladım ve kullanıcı dostu bir tasarım verdim.JavaScript tarafında ise document.querySelector() metodunu kullanarak form ve kullanıcı adı giriş alanına ulaştım. Daha sonra addEventListener ile formun gönderilme (submit) olayını yakaladım. Burada önemli bir nokta, varsayılan form gönderme davranışını durdurmak için e.preventDefault() metodunu kullandım. Böylece sayfa yenilenmeden kullanıcıdan alınan bilgiyi işleyebildim.Kullanıcı formu gönderdiğinde console.log(username.value) kodu sayesinde girilen kullanıcı adını tarayıcı konsoluna yazdırdım. Bu yöntem sayesinde form verilerinin JavaScript ile nasıl okunabileceğini ve yönetilebileceğini öğrenmiş oldum.Bugünün sonunda HTML formlarının sadece veri girişi için değil, aynı zamanda JavaScript ile kontrol edilip dinamik hale getirilebildiğini kavradım.
Today in my internship, I worked on HTML form tags and how to control them with JavaScript. First, I created a simple form structure. I defined an input[type="text"] button to enter the username within the form and a submit button to submit the form. I centered the form with CSS and gave it a user-friendly design. On the JavaScript side, I used the document.querySelector() method to access the form and username input fields. Then, I used addEventListener to capture the form's submit event. Importantly, I used the e.preventDefault() method to prevent the default form submission behavior. This allowed me to process the user's data without refreshing the page. When the user submitted the form, the console.log(username.value) code printed the entered username to the browser console. This method taught me how to read and manage form data with JavaScript. By the end of the day, I understood that HTML forms are not only for data entry but can also be controlled and made dynamic with JavaScript.