Skip to content

WD ATTR Vform Tool

wdonadelli edited this page Apr 27, 2022 · 3 revisions

WD ATTR Vform Tool

The reference for how the attribute works is in the following tools:

The attribute's destination is the element itself (form) that contains it and the result influences the validity of the field in the requests and filling of the field.

the attribute value is the name of the check function that must be within the scope of window to be found.

The function accepts an argument where the element containing the attribute will be passed. After checking, if no undue value was found, the function should return null or undefined, otherwise, it should return the text with the error message.

<script>
/* Checks for prohibited names */
function myCheck(e) {
	let list = [
		"mario", "mary", "paul", "lucas", "maria", "alfred", "lisa"
	];
	let value = e.value.toLowerCase().trim();
	if (list.indexOf(value) < 0 ) return null;
	return value.toUpperCase() + " is not an allowed name.";
}
</script>

<form id="myForm">
	<input data-wd-vform="myCheck" required="" type="text" name="name" placeholder="Enter a name"/>
	<button type="button" data-wd-send="path{target.php}$${#myForm > *}" >Send</button>
</form>

Clone this wiki locally