Skip to content

Commit

Permalink
Prepared for version 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
hsnaydd committed Jul 9, 2014
1 parent 46d518f commit 27e21b9
Show file tree
Hide file tree
Showing 12 changed files with 26 additions and 28 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "validetta",
"description": "A tiny jquery plugin for validate your forms",
"version": "0.9.0",
"version": "1.0.0",
"homepage": "http://lab.hasanaydogdu.com/validetta/",
"author": {
"name": "Hasan Aydoğdu",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 0 additions & 1 deletion demo/remote.php → demo/files/remote.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php
sleep(3);
$response = array( 'valid' => false, 'message' => 'Sorry, Something went wrong!');
if( isset($_POST['exm3-name']) ) {

Expand Down
10 changes: 5 additions & 5 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>Form Validator - Examples</title>
<link rel="stylesheet" type="text/css" href="../src/validetta.css">
<link rel="stylesheet" type="text/css" href="../dist/validetta.css">
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="jquery.js?v1.10.2"><\/script>')</script>
<script type="text/javascript" src="../src/validetta.js"></script>
<script>window.jQuery || document.write('<script src="files/jquery.js?v1.10.2"><\/script>')</script>
<script type="text/javascript" src="../dist/validetta.js"></script>
<!--
<script type="text/javascript" src="../localization/validettaLang-tr-TR.js"></script>
-->
Expand Down Expand Up @@ -36,7 +36,7 @@
// this -> form object
// this.form is form element
$.ajax({
url : 'ajax.json',
url : 'files/ajax.json',
data : $(this.form).serialize(),
dataType : 'json',
beforeSend : function(){
Expand Down Expand Up @@ -66,7 +66,7 @@
remote : {
check_username : {
type : 'POST',
url : 'remote.php',
url : 'files/remote.php',
datatype : 'json'
}
}
Expand Down
2 changes: 1 addition & 1 deletion dist/validetta.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*!
* Validetta (http://lab.hasanaydogdu.com/validetta/)
* Version 0.9.0 ( 19-06-2014 )
* Version 1.0.0 ( 09-07-2014 )
* Licensed under MIT (https://github.com/hsnayd/validetta/blob/master/LICENCE)
* Copyright 2013-2014 Hasan Aydoğdu - http://www.hasanaydogdu.com
*/
Expand Down
27 changes: 13 additions & 14 deletions dist/validetta.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*!
* Validetta (http://lab.hasanaydogdu.com/validetta/)
* Version 0.9.0 ( 19-06-2014 )
* Version 1.0.0 ( 09-07-2014 )
* Licensed under MIT (https://github.com/hsnayd/validetta/blob/master/LICENCE)
* Copyright 2013-2014 Hasan Aydoğdu - http://www.hasanaydogdu.com
*/
Expand All @@ -13,7 +13,7 @@
var Validetta = {}, // Plugin Class
FIELDS = {}, // Current fields/fields
// RegExp for input validate rules
RRULE = new RegExp( /^(minChecked|maxChecked|minSelected|maxSelected|minLength|maxLength|equalTo|customReg|remote)\[(\w{1,15})\]/i ),
RRULE = new RegExp( /^(minChecked|maxChecked|minSelected|maxSelected|minLength|maxLength|equalTo|custom|remote)\[(\w{1,15})\]/i ),
// RegExp for mail control method
// @from ( http://www.whatwg.org/specs/web-apps/current-work/multipage/states-of-the-type-attribute.html#e-mail-state-%28type=email%29 )
RMAIL = new RegExp( /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/ ),
Expand Down Expand Up @@ -50,7 +50,7 @@
realTime : false, // To enable real-time form control, set this option true.
onValid : function(){}, // This function to be called when the user submits the form and there is no error.
onError : function(){}, // This function to be called when the user submits the form and there are some errors
customReg : {}, // Costum reg method variable
custom : {}, // Costum reg method variable
remote : {}
},

Expand Down Expand Up @@ -162,9 +162,9 @@
return count === 1;
},
// Custom reg check
customReg : function( tmp, self ) {
var _arg = self.options.customReg[ tmp.arg ],
_reg = new RegExp( _arg.method );
custom : function( tmp, self ) {
var _arg = self.options.custom[ tmp.arg ],
_reg = new RegExp( _arg.pattern );
return _reg.test( tmp.val ) || _arg.errorMessage;
},
remote : function( tmp ) {
Expand Down Expand Up @@ -288,8 +288,6 @@
// Start to check fields
// Validator : Fields Control Object
for ( var j = methods.length - 1; j >= 0; j-- ) {
// prevent empty validation if method is not required
if ( val === '' && methods[ j ] !== 'required' ) continue;
// Check Rule
var rule = methods[ j ].match( RRULE ),
method;
Expand All @@ -300,6 +298,8 @@
// Set method name
method = rule[1];
} else { method = methods[ j ]; }
// prevent empty validation if method is not required
if ( val === '' && method !== 'required' && method !== 'equalTo' ) continue;
// Is there a methot in Validator ?
if( Validator.hasOwnProperty( method ) ) {
// Validator returns error message if method invalid
Expand All @@ -319,6 +319,7 @@
} else { // Nice, there are no error
if( typeof state !== 'undefined' ) this.addValidClass( this.tmp.parent );
else $( this.tmp.parent ).removeClass( this.options.errorClass +' '+ this.options.validClass );
state = undefined; // Reset state variable
}
}
},
Expand Down Expand Up @@ -447,15 +448,13 @@
errorObject.className = this.options.errorTemplateClass;
// if error display is bubble, calculate to positions
if( this.options.display === 'bubble' ) {
var pos, W, H, T;
var pos, W;
// !! Here, JQuery functions are using to support the IE8
pos = $( el ).position();
W = $( el ).width();
H = $( el ).height();
T= pos.top ;
W = $( el ).outerWidth(true);
$( errorObject ).empty().css({
'left' : pos.left + W + 30 +'px',
'top' : T +'px'
'left' : pos.left + W + 15 +'px',
'top' : pos.top +'px'
});
}
elParent.appendChild( errorObject );
Expand Down
2 changes: 1 addition & 1 deletion dist/validetta.min.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*!
* Validetta (http://lab.hasanaydogdu.com/validetta/)
* Version 0.9.0 ( 19-06-2014 )
* Version 1.0.0 ( 09-07-2014 )
* Licensed under MIT (https://github.com/hsnayd/validetta/blob/master/LICENCE)
* Copyright 2013-2014 Hasan Aydoğdu - http://www.hasanaydogdu.com
*/
Expand Down
Loading

0 comments on commit 27e21b9

Please sign in to comment.