Search This Blog

Friday, May 18, 2012

How to check your page is valid?

function ValidatePage() {

if (typeof (Page_ClientValidate) == 'function') {
Page_ClientValidate();
}

if (Page_IsValid) {
// do something
alert('Page is valid!');
}
else {
// do something else
alert('Page is not valid!');
}
}

Thursday, May 3, 2012

How to rerturn value from showmodaldialog

Using the following javascript code you can return a variant value from modaldialog window to parent window.
When you call showModalDialog you do this:
Code:
var oReturnValue = window.showModalDialog("subDoc.html",argsVariable, "dialogWidth:300px; dialogHeight:200px; center:yes");
Within showModalDialog, assuming your textboxes have IDs of "txtForename" and "txtSurname":
Code:
function terminate()
{
var o = new Object();
o.forename = document.getElementById("txtForename").value;
o.surname = document.getElementById("txtSurname").value;
window.returnValue = o;
}


Then continuing in your main window:
Code:

alert(oReturnValue.forename + "\n" + oReturnValue.surname);