// Object to store initial values of textboxes
var initialValues = {
textbox1: "10",
textbox2: "20"
};
// Function to set initial values
function setInitialValue(id, value) {
initialValues[id] = value;
}
// Function to check for changes and update password field
function checkForChanges(id) {
var textbox = document.getElementById(id);
var passwordField = document.getElementById('password');
// Make password field mandatory if the value has changed
passwordField.required = initialValues[id] !== textbox.value;
}
// Function to validate the form on submit
function validateForm() {
// Additional validation logic can be added here if needed
if (!checkAdditionalValidation()) {
return false; // Prevent form submission
}
return true; // Allow form submission
}
// Function to handle additional validation (you can customize this)
function checkAdditionalValidation() {
// Example: Check if some condition is met
// Return true to allow form submission, or false to prevent it
return true;
}
// Set initial values on page load
window.onload = function () {
setInitialValue('textbox1', document.getElementById('textbox1').value);
setInitialValue('textbox2', document.getElementById('textbox2').value);
};
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.