Skip to content

Commit d2ca859

Browse files
committed
Bugfix IE validateURL / lengthRestriction
IE 8 has problems with splitting regex-strings. this is an easy work-around. lenghtRestriction didn't count characters, that were filled before domready (for example serverside <textarea>here is prefilled text</textarea>)
1 parent 217b147 commit d2ca859

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

jquery.formvalidator.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1034,7 +1034,7 @@ jQueryFormUtils.validateUrl = function(url) {
10341034
// contributed by Scott Gonzalez: http://projects.scottsplayground.com/iri/ but added support for arrays in the url ?arg[]=sdfsdf
10351035
var urlFilter = /^(https|http|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|\[|\]|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i;
10361036
if(urlFilter.test(url)) {
1037-
var domain = url.split(/^https|^http|^ftp/i)[1].replace('://', '');
1037+
var domain = url.split('://')[1];
10381038
var domainSlashPos = domain.indexOf('/');
10391039
if(domainSlashPos > -1)
10401040
domain = domain.substr(0, domainSlashPos);
@@ -1060,6 +1060,8 @@ jQueryFormUtils.lengthRestriction = function(inputElement, maxLengthElement) {
10601060
$(inputElement).bind('keydown keyup keypress focus blur', countCharacters )
10611061
.bind('cut paste', function(){ setTimeout(countCharacters, 100); } )
10621062
;
1063+
// count chars on pageload, if there are prefilled input-values
1064+
$(document).bind("ready",countCharacters);
10631065
// internal function does the counting and sets display value
10641066
function countCharacters(){
10651067
var numChars = inputElement.val().length;
@@ -1073,4 +1075,5 @@ jQueryFormUtils.lengthRestriction = function(inputElement, maxLengthElement) {
10731075
// set counter text
10741076
maxLengthElement.text(maxChars - numChars);
10751077
};
1078+
10761079
};

0 commit comments

Comments
 (0)