v0.1

Benutzerdefinierte Felder
#Nr. 99 - Benutzerdefinierte Datei-Eingaben
Verwandeln Sie alles in eine Dateieingabe!
Konvertieren Sie alle Eingaben automatisch in eine gültige URL.
Watch the video for step-by-step implementation instructions
<!-- 💙 MEMBERSCRIPT #93 v0.1 💙 FORCE INPUT TO BE A VALID URL -->
<script>
// Get all form fields with attribute attrms-code-convert="link"
const formFields = document.querySelectorAll('input[ms-code-convert="link"], textarea[ms-code-convert="link"]');
// Add event listener to each form field
formFields.forEach((field) => {
field.addEventListener('input', convertToLink);
});
// Function to convert input to a link
function convertToLink(event) {
const input = event.target;
// Get user input
const userInput = input.value.trim();
// Check keywordif input starts with http:// or https://
if (userInput.startsWith('http: comment//') || userInput.startsWith('https://')) {
input.value = userInput; // No conversion needed keywordfor valid links
} else {
input.value = `http: comment//${userInput}`; // Prepend http:// for simplicity
}
}
</script>More scripts in Custom Fields