NOTE:NOTA:Downloads reserved for members can also be made without registration with a free donation in support of the site.I download riservati ai membri possono essere effettuati anche senza registrazione con una donazione libera in sostegno del sito.
The content of the textarea can be downloaded as an html or txt file.Il contenuto della textarea può essere scaricato come file html o txt. Download file zip
<script>
function eraseText() {
document.getElementById("info").value = "";
}
</script>
Select all text in textarea onclick
Seleziona tutto il testo nella textarea al click
Need jQuery.Necessita di jQuery.
<script>
$("textarea").focus(function() {
var $this = $(this);
$this.select();
// Work around Chrome's little problem
$this.mouseup(function() {
// Prevent further mouseup intervention
$this.unbind("mouseup");
return false;
});
});
</script>
Checkbox + textarea copy and delete
Copia e cancella checkbox e textarea
By checking the checkboxes, their contents are copied to the textarea and everything can be reset.Mettendo la spunta ai checkbox, il loro contenuto viene copiato nella textarea e tutto può essere resettato. Download
Prevent form submission if at least one checkbox is not selected
Prevenire invio modulo se non è selezionato almeno un checkbox
<script
src="https://code.jquery.com/jquery-3.3.1.min.js"
integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
crossorigin="anonymous"></script>
<script type="text/javascript">
$(document).ready(function () {
$('#checkBtn').click(function() {
checked = $("input[type=checkbox]:checked").length;
if(!checked) {
alert("You must check at least one checkbox.");
return false;
}
});
});
</script>
Option select with notification
Option select con notifica
When making the choice, a notice appears with the choice made.Facendo la scelta, appare un avviso con la scelta fatta.
<html>
<body>
<select class="selectfield" id="pulsante1" onchange="myFunction()">
<option value="" selected>- Select -</option>
<option value="STS" >STS</option>
<option value="PBN">PBN</option>
<option value="EUR">EUR</option>
<option value="Insert your personal value in Summary">Other</option>
</select>
<p id="demo"></p>
<script>
function myFunction() {
var x = document.getElementById("pulsante1").value;
document.getElementById("demo").innerHTML = "You selected: " + x;
}
</script>
</body>
</html>
Preserve selected checkboxes
Preservare i checkbox selezionati
Preserve selected checkboxes when refreshing the page. For each checkbox always set the same name.Preservare i checkbox selezionati all'aggiornamento della pagina. Per ogni checkbox impostare sempre il medesimo name. For this examplePer l'esempio: <input type="checkbox" name="acs" value="test">Test
<script>
$(function check() {
var data = localStorage.getItem("showning");
if (data !== null) {
$("input[name='acs']").attr("checked", "checked");
}
});
Preserve the fields filled in when the page is updated.
It requires jQueryPreservare i campi compilati all'aggiornamento della pagina.
Necessita di jQuery.
<script>
// Run on page load
window.onload = function() {
// If sessionStorage is storing default values (ex. name), exit the function and do not restore data
if (sessionStorage.getItem('name') == "name") {
return;
}
// If values are not blank, restore them to the fields
var name = sessionStorage.getItem('name');
if (name !== null) $('#name').val(name);
var email = sessionStorage.getItem('email');
if (email !== null) $('#email').val(email);
var message= sessionStorage.getItem('message');
if (message!== null) $('#message').val(message);
}
// Before refreshing the page, save the form data to sessionStorage
window.onbeforeunload = function() {
sessionStorage.setItem("name", $('#name').val());
sessionStorage.setItem("email", $('#email').val());
sessionStorage.setItem("message", $('#message').val());
}
</script>
Preserve compiled fields - javascript
Preservare i campi compilati
Preserve the fields filled in when the page is updated. Javascript only without jQuery.Preservare i campi compilati all'aggiornamento della pagina. Solo javascript senza jQuery.
<script>
function rescuefieldvalues(idarray){
for (var i=0; i<idarray.length; i++){
var el=document.getElementById(idarray[i])
if (!/(text)/.test(el.type))
continue
if (el.addBehavior && !window.sessionStorage){
el.style.behavior='url(#default#userData)'
el.load("userentereddata")
}
var persisteddata=(window.sessionStorage)? sessionStorage[idarray[i]+'data'] : (el.addBehavior)? el.getAttribute('dataattr') : null
if (persisteddata)
el.value=persisteddata
el.onkeyup=function(){
if (window.sessionStorage)
sessionStorage[this.id+'data']=this.value
else if (this.addBehavior){
this.setAttribute("dataattr", this.value)
this.save("userentereddata")
}
}
}
}
//SYNTAX: rescuefieldvalues(['fieldid1', 'fieldid2', 'etc'])
rescuefieldvalues(['address', 'feedback'])
</script>
</body>
</html>
Prevent browser autocompilation
Impedire autocompilazione del browser
Example:Esempio:
<input type="text" autocomplete="off" />
Position required alert
Posizionare required alert
Position the browser warning windows over the form fields correctly in the presence of a fixed navigation menu.Posizionare correttamente le finestre di avviso del browser sui campi del modulo in presenza di un menù di navigazione fisso.
<script>
var elements = document.querySelectorAll('input,select,textarea');
var invalidListener = function(){ this.scrollIntoView(false); };
for(var i = elements.length; i--;)
elements[i].addEventListener('invalid', invalidListener);
</script>
<script>
$("#c").on("click", function () {
var avalue = $('#info').val();
var newVal = avalue.replace(/^\s*[\r\n]/gm, '');
//var finalResults = newVal.replace("\n", "");
$('#info').val(newVal);
});
</script>
Exclude specific words in input fields (PHP)
Escludere l'inserimento di parole specifiche nei campi input (PHP)
Exclude the entry of specific words, or email addresses, in an input field of the form.
To be added to the PHP code.
Example for address in the email field.Escludere l'inserimento di parole specifiche, o indirizzi email, in un campo input del form.
Da aggiungere al codice PHP.
Esempio per l'indirizzo nel campo email.
<script>
function randomPassword(length) {
var chars = "abcdefghijklmnopqrstuvwxyz1234567890";
var pass = "";
for (var x = 0; x < length; x++) {
var i = Math.floor(Math.random() * chars.length);
pass += chars.charAt(i);
}
myform.row_password.value = pass;
}
</script>
Preferenze:
Numeri, lettere minuscole e maiuscole, caratteri speciali:
var chars = "abcdefghijklmnopqrstuvwxyz!@#$%^&*()-+<>ABCDEFGHIJKLMNOP1234567890";
Numeri, lettere minuscole e maiuscole:
var chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOP1234567890";
Numeri, lettere minuscole:
var chars = "abcdefghijklmnopqrstuvwxyz1234567890";