-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve phone number input style on signup form and fix bugs in users…
… models.
- Loading branch information
1 parent
343c09b
commit aa0ccb2
Showing
4 changed files
with
46 additions
and
8 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// This script modifies the display of the phone prefix dropdown (id_phone_0) to show only the country code after selection. | ||
// The full country name and code are restored when the dropdown is clicked for a better user experience. | ||
document.addEventListener("DOMContentLoaded", function() { | ||
const phoneSelect = document.getElementById("id_phone_0"); | ||
|
||
// Function to update the display after selection | ||
function updateDisplay() { | ||
const selectedOption = phoneSelect.options[phoneSelect.selectedIndex]; | ||
const countryCode = selectedOption.text.match(/\+[\d]+/); // Extracts the country code | ||
if (countryCode) { | ||
phoneSelect.style.width = "auto"; // Allow the width to adjust to the content | ||
selectedOption.textContent = countryCode[0]; // Show only the country code | ||
} | ||
} | ||
|
||
// Initial update | ||
updateDisplay(); | ||
|
||
// Restore full text when the dropdown is clicked | ||
phoneSelect.addEventListener("click", function() { | ||
Array.from(phoneSelect.options).forEach(option => { | ||
option.textContent = option.getAttribute("data-full-text") || option.textContent; | ||
}); | ||
}); | ||
|
||
// Update the display after selection | ||
phoneSelect.addEventListener("change", function() { | ||
updateDisplay(); | ||
}); | ||
}); |
This file contains 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
This file contains 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
This file contains 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