I decided that first I will try to find something on the Internet. Maximum time for that is 20 minutes, after that I’m fixing it on my own.
After about 5 minutes I have found a fix for that.
I found it on ASP.NET forums. It’s a post by jgallant (Joe Gallant I presume)
http://forums.asp.net/296304/ShowPost.aspx Check out Joe's post on how to implement it.
I found that the posted WebUIValidation.js file didn’t worked for me, so I fixed it.
Plus I added a little patch that when a button doesn’t have assigned validator it validates all (before JavaScript error showed up)
You can view and download my version of this file WebUIValidation.js.txt (look out for the txt extension).
Big thanks Joe for posting this and for a detailed explanation.
Blogger does not let you attach files to posts so here is the content of the "WebUIValidation.js" file
var Page_ValidationVer = "125";
var Page_IsValid = true;
var Page_BlockSubmit = false;
function ValidatorUpdateDisplay(val) {
if (typeof(val.display) == "string") {
if (val.display == "None") {
return;
}
if (val.display == "Dynamic") {
val.style.display = val.isvalid ? "none" : "inline";
return;
}
}
val.style.visibility = val.isvalid ? "hidden" : "visible";
}
function ValidatorUpdateIsValid() {
var i;
for (i = 0; i < page_isvalid =" false;" page_isvalid =" true;" ctrl =" document.all[controlID];" isvalid =" true;" enabled =" false;" i =" 0;" inner =" control;" i =" 0;" validators =" new" type ="="" ev =" control.onclick;" ev =" control.onchange;" ev =" ev.toString();" ev =" ev.substring(ev.indexOf(" ev = "" func =" new" type ="="" onclick =" func;" onchange =" func;" control =" document.all[id];" j="0;" inner =" control[j];" status ="="" status ="="" i =" 0;">
num = parseFloat(cleanInput);
return (isNaN(num) ? null : num);
}
else if (dataType == "Currency") {
exp = new RegExp("^\\s*([-\\+])?(((\\d+)\\" + val.groupchar + ")*)(\\d+)"
+ ((val.digits > 0) ? "(\\" + val.decimalchar + "(\\d{1," + val.digits + "}))?" : "")
+ "\\s*$");
m = op.match(exp);
if (m == null)
return null;
var intermed = m[2] + m[5] ;
cleanInput = m[1] + intermed.replace(new RegExp("(\\" + val.groupchar + ")", "g"), "") + ((val.digits > 0) ? "." + m[7] : 0);
num = parseFloat(cleanInput);
return (isNaN(num) ? null : num);
}
else if (dataType == "Date") {
var yearFirstExp = new RegExp("^\\s*((\\d{4})|(\\d{2}))([-./])(\\d{1,2})\\4(\\d{1,2})\\s*$");
m = op.match(yearFirstExp);
var day, month, year;
if (m != null && (m[2].length == 4 || val.dateorder == "ymd")) {
day = m[6];
month = m[5];
year = (m[2].length == 4) ? m[2] : GetFullYear(parseInt(m[3], 10))
}
else {
if (val.dateorder == "ymd"){
return null;
}
var yearLastExp = new RegExp("^\\s*(\\d{1,2})([-./])(\\d{1,2})\\2((\\d{4})|(\\d{2}))\\s*$");
m = op.match(yearLastExp);
if (m == null) {
return null;
}
if (val.dateorder == "mdy") {
day = m[3];
month = m[1];
}
else {
day = m[1];
month = m[3];
}
year = (m[5].length == 4) ? m[5] : GetFullYear(parseInt(m[6], 10))
}
month -= 1;
var date = new Date(year, month, day);
return (typeof(date) == "object" && year == date.getFullYear() && month == date.getMonth() && day == date.getDate()) ? date.valueOf() : null;
}
else {
return op.toString();
}
}
function ValidatorCompare(operand1, operand2, operator, val) {
var dataType = val.type;
var op1, op2;
if ((op1 = ValidatorConvert(operand1, dataType, val)) == null)
return false;
if (operator == "DataTypeCheck")
return true;
if ((op2 = ValidatorConvert(operand2, dataType, val)) == null)
return true;
switch (operator) {
case "NotEqual":
return (op1 != op2);
case "GreaterThan":
return (op1 > op2);
case "GreaterThanEqual":
return (op1 >= op2);
case "LessThan":
return (op1 < op1 ="="" value =" ValidatorGetValue(val.controltovalidate);" length ="="" compareto = "" null ="="" compareto =" val.valuetocompare;" compareto =" ValidatorGetValue(val.controltocompare);" value = "" value =" ValidatorGetValue(val.controltovalidate);" length ="="" args =" {" value =" ValidatorGetValue(val.controltovalidate);" length ="="" rx =" new" matches =" rx.exec(value);" value ="="" m =" s.match(/^\s*(\S+(\s+\S+)*)\s*$/);" m ="="" value =" ValidatorGetValue(val.controltovalidate);" length ="="" sums =" 0;" summary =" Page_ValidationSummaries[sums];" display = "none" display = "" displaymode = "BulletList" headersep =" ">
";
first = "";
pre = "";
post = "
";
final = "";
break;
case "BulletList":
default:
headerSep = "";
first = "
- ";
- ";
post = " ";
pre = "
final = "
break;
case "SingleParagraph":
headerSep = " ";
first = "";
pre = "";
post = " ";
final = "
";
break;
}
s = "";
if (typeof(summary.headertext) == "string") {
s += summary.headertext + headerSep;
}
s += first;
for (i=0; i
";
}
for (i=0; i
";
break;
case "BulletList":
default:
s += " - " + Page_Validators.errormessage + "
";
break;
case "SingleParagraph":
s += Page_Validators.errormessage + " ";
break;
}
}
}
span = document.createElement("SPAN");
span.innerHTML = s;
s = span.innerText;
alert(s);
}
}
}
}
function InArray(array, value, attribute)
{
if( attribute != null )
attribute += ".";
for(var i = 0; i <>
{
if( eval('array.' + attribute + 'toString().toLowerCase()') == value.toString().toLowerCase() )
return i;
}
return -1;
}
No comments:
Post a Comment