<commit_before>// ===================================================================
// Author: <NAME> <<EMAIL>>
// 
//
// NOTICE: You may use this code for any purpose, commercial or
// private, without any further permission from the author. You may
// remove this notice from your final code if you wish.
//
// You may *NOT* re-distribute this code in any way except through its
// use. That means, you can include it in your product, or your web
// site, or any other form where the code is actually being used. You
// may not put the plain javascript up on your site for download or
// include it in your javascript libraries for download. 
// If you wish to share this code with others, please just point them
// to the URL instead.
// Please DO NOT link directly to my .js files from your site. Copy
// the files to your server and use them there. Thank you.
// ===================================================================

// ------------------------------------------------------------------
// The css class names are case insensitive and define the validations
// an input should go thorgh before its validated and submitted.
// The following validations are provided out of box using commons-validations:
// 
// Validation Type  | CSS Class Name     | usage
// -----------------+--------------------+-----------------------
// Required         | NOTEMPTY           | <[input][select][textarea] type=[text][password] class=validate-NOTEMPTY
// Minimum Length   | MINLENGTH          | <[input].... type=.... class=validate-MINLENGTH<length>
// Maximum Length   | MAXLENGTH          | <[input].... type=.... class=validate-MAXLENGTH<length>
// Email            | EMAIL              | <[input].... type=.... class=validate-EMAIL
// Credit Card      | VISA,etc           | <[input].... type=.... class=validate-VISA[etc]
// Zip code         | ZIPCODE            | <[input].... type=.... class=validate-ZIPCODE
// Zip or Postal    | ZIP_POSTAL_CODE    | <[input].... type=.... class=validate-ZIP_POSTAL_CODE
// US Phone No.     | US_PHONE_NO        | <[input].... type=.... class=validate-US_PHONE_NO
// Alphanumeric     | ALPHANUMERIC       | <[input].... type=.... class=validate-ALPHANUMERIC
// Numeric          | NUMERIC            | <[input].... type=.... class=validate-NUMERIC
// Alphabetic       | ALPHABETIC         | <[input].... type=.... class=validate-ALPHABETIC
// date             | DATE               | <[input].... type=.... class=validate-DATE[(<format>)]
//
// NOTE : For Multiple validation use JAVA 'and' notation ('&&').
// Example:
//  <[input].... type=.... class=validate-NOTEMPTY&&MINLENGTH7&&EMAIL
// ------------------------------------------------------------------

Event.observe(window, "load", function(){
	$$('form').each(function(formVar){
									formVar._submit= formVar.submit
									formVar.submit = validateForm
									Event.observe(formVar, "submit", validateForm)
								})
})
validateForm=function(submit){
	formVar=submit?Event.element(submit):this
	submit?Event.stop(submit):null
	var fields=Form.getElements(formVar)
	var checkFields=fields.findAll(function(field){
						className=Element.classNames(field).detect(function(cls) {
															var v=cls.indexOf('validate') == 0
															return cls.indexOf('validate') == 0
														})
						return className==null?false:className.length>0
					})
	checkFields.each(prepareField)
	flag=validateFields(checkFields)
	if(flag){
		formVar._submit()
	}
}
prepareField=function(element){
	ERROR_MSG_REQUIRED="required"
	ERROR_MSG_PATTERN="Incorrect format"<commit_msg>added a callback method on submit<commit_after>// ===================================================================
// Author: <NAME> <<EMAIL>>
// 
//
// NOTICE: You may use this code for any purpose, commercial or
// private, without any further permission from the author. You may
// remove this notice from your final code if you wish.
//
// You may *NOT* re-distribute this code in any way except through its
// use. That means, you can include it in your product, or your web
// site, or any other form where the code is actually being used. You
// may not put the plain javascript up on your site for download or
// include it in your javascript libraries for download. 
// If you wish to share this code with others, please just point them
// to the URL instead.
// Please DO NOT link directly to my .js files from your site. Copy
// the files to your server and use them there. Thank you.
// ===================================================================

// ------------------------------------------------------------------
// The css class names are case insensitive and define the validations
// an input should go thorgh before its validated and submitted.
// The following validations are provided out of box using commons-validations:
// 
// Validation Type  | CSS Class Name     | usage
// -----------------+--------------------+-----------------------
// Required         | NOTEMPTY           | <[input][select][textarea] type=[text][password] class=validate-NOTEMPTY
// Minimum Length   | MINLENGTH          | <[input].... type=.... class=validate-MINLENGTH<length>
// Maximum Length   | MAXLENGTH          | <[input].... type=.... class=validate-MAXLENGTH<length>
// Email            | EMAIL              | <[input].... type=.... class=validate-EMAIL
// Credit Card      | VISA,etc           | <[input].... type=.... class=validate-VISA[etc]
// Zip code         | ZIPCODE            | <[input].... type=.... class=validate-ZIPCODE
// Zip or Postal    | ZIP_POSTAL_CODE    | <[input].... type=.... class=validate-ZIP_POSTAL_CODE
// US Phone No.     | US_PHONE_NO        | <[input].... type=.... class=validate-US_PHONE_NO
// Alphanumeric     | ALPHANUMERIC       | <[input].... type=.... class=validate-ALPHANUMERIC
// Numeric          | NUMERIC            | <[input].... type=.... class=validate-NUMERIC
// Alphabetic       | ALPHABETIC         | <[input].... type=.... class=validate-ALPHABETIC
// date             | DATE               | <[input].... type=.... class=validate-DATE[(<format>)]
//
// NOTE : For Multiple validation use JAVA 'and' notation ('&&').
// Example:
//  <[input].... type=.... class=validate-NOTEMPTY&&MINLENGTH7&&EMAIL
// ------------------------------------------------------------------

Event.observe(window, "load", function(){
	$$('form').each(function(formVar){
									formVar._submit= formVar.submit
									formVar.submit = validateForm
									Event.observe(formVar, "submit", validateForm)
								})
})
validateForm=function(submit){
	formVar=submit?Event.element(submit):this
	submit?Event.stop(submit):null
	var fields=Form.getElements(formVar)
	var checkFields=fields.findAll(function(field){
						className=Element.classNames(field).detect(function(cls) {
															var v=cls.indexOf('validate') == 0
															return cls.indexOf('validate') == 0
														})
						return className==null?false:className.length>0
					})
	checkFields.each(prepareField)
	flag=validateFields(checkFields)
	if(flag){
		ret=(submitPostProcess?submitPostProcess(formVar):true)
		ret?formVar._submit():null
	}
}
var submitPostProcess
prepareField=function(element){
	ERROR_MSG_REQUIRED="required"
	ERROR_MSG_PATTERN="Incorrect fromat"
{'fraction_non_alphanumeric': 0.2210179722870078, 'fraction_numerical': 0.0010975442447523666, 'mean_word_length': 2.3211845102505695, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4812058', 'n_tokens_mistral': 2145, 'n_tokens_neox': 1927, 'n_words': 581}