Form validation using custom function

Legal Range

The code

window.addEvent('domready', pageInitial);
var avLockCheck = null;

function pageInitial() {
	avLockCheck = new FormCheck('formular');
}

var avlock = false;
function avorder(el) {
	if( avlock )  return true;
	avlock = true;

	var elParent = el.getParent('div');

	var minEl = elParent.getElement("[name^=min]");
	var maxEl = elParent.getElement("[name^=max]");

	if( avLockCheck.validate( minEl ) && avLockCheck.validate( maxEl ) &&
						Number(minEl.value) > Number(maxEl.value) ) {
	var errorMsg = (el == minEl ?
		"This value is great than maximum." :
		"This value is less than minimum." );
		el.errors.push( errorMsg );

		avlock = false;
		return false;
	}

	avlock = false;
	return true;
}

Options

Use a function to perform custom check. See source code and the documentation for further informations.

Theme

blue