Skip to content

jQuery Validation

Mark Howells-Mead edited this page Oct 9, 2019 · 1 revision

General rules

  • Reference documentation
  • Make sure that every field which has to be validated has a name attribute. Otherwise, the validation result will be applied to the first field which jqueryvalidation can find in the form.

Custom validation function

$.validator.addMethod('validTime', function(value, element) {
	// 10:00:00
	return /^([0-9]|0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]$/.test(value);
}, 'Invalid time');
Clone this wiki locally