-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #48 from nthachus/master
Improve to use HTML5 attributes for laravel 5
- Loading branch information
Showing
26 changed files
with
1,773 additions
and
393 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,5 @@ | |
composer.phar | ||
composer.lock | ||
.DS_Store | ||
Thumbs.db | ||
.idea/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,54 @@ | ||
$.validator.addMethod("regex", function(value, element, regexp) { | ||
var regex = new RegExp(regexp); | ||
return this.optional(element) || regex.test(value); | ||
}, 'Format is invalid'); | ||
$.extend($.validator.methods, { | ||
maxlength: function (value, element, param) { | ||
if (this.optional(element)) | ||
return true; | ||
|
||
var length = (element.files && element.files.length) ? element.files[0].size / 1024 | ||
: ($.isArray(value) ? value.length : this.getLength(value, element)); | ||
return length <= param; | ||
} | ||
}); | ||
|
||
// Return true if the field value matches the given format RegExp | ||
$.validator.addMethod("pattern", function (value, element, param) { | ||
if (this.optional(element)) | ||
return true; | ||
|
||
if (typeof param === "string") | ||
param = new RegExp(param.charAt(0) == "^" ? param : "^(?:" + param + ")$"); | ||
return param.test(value); | ||
}, "Invalid format."); | ||
|
||
$.validator.addMethod("notEqualTo", function (value, element, param) { | ||
return this.optional(element) || !$.validator.methods.equalTo.call(this, value, element, param); | ||
}, "Please enter a different value, values must not be the same."); | ||
|
||
$.validator.addMethod("integer", function (value, element) { | ||
return this.optional(element) || /^-?\d+$/.test(value); | ||
}, "A positive or negative non-decimal number please"); | ||
|
||
$.validator.addMethod("ipv4", function (value, element) { | ||
return this.optional(element) | ||
|| /^(25[0-5]|2[0-4]\d|[01]?\d\d?)\.(25[0-5]|2[0-4]\d|[01]?\d\d?)\.(25[0-5]|2[0-4]\d|[01]?\d\d?)\.(25[0-5]|2[0-4]\d|[01]?\d\d?)$/i.test(value); | ||
}, "Please enter a valid IP v4 address."); | ||
|
||
// Accept a value from a file input based on a required mime-type | ||
$.validator.addMethod("accept", function (value, element, param) { | ||
// Browser does not support element.files and the FileList feature | ||
if (this.optional(element) || $(element).attr("type") !== "file" || !element.files || !element.files.length) | ||
return true; | ||
|
||
// Split mime on commas in case we have multiple types we can accept | ||
var typeParam = typeof param === "string" ? param.replace(/\s+/g, "") : "image/*", | ||
// Escape string to be used in the regex | ||
regex = new RegExp(".?(" + typeParam.replace(/[\-\[\]\/\{}\(\)\+\?\.\\\^\$\|]/g, "\\$&").replace(/,/g, "|").replace(/\/\*/g, "/.*") + ")$", "i"); | ||
|
||
// Grab the mime-type from the loaded file, verify it matches | ||
for (var i = 0; i < element.files.length; i++) { | ||
if (!regex.test(element.files[i].type)) | ||
return false; | ||
} | ||
|
||
// We've validated each file | ||
return true; | ||
}, "Please enter a value with a valid mime-type."); |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.