hoffmandirt
May 16th, 2005, 06:31 PM
I have a page that has required field validators all over it. I also needed to validate a couple text boxes and display a confirmation. I did this using this code:
btnSave.Attributes["onclick"] += "return valSubmit();";
I also tried:
btnSave.Attributes.Add("onclick", "return valSubmit();");
but this keeps canceling out my validators. I would like the user to click on the button, recieve the confirmation and then if there are any empty required fields to then be notified. I was reading some where that you need to read through the keys and add the new one in but i can't seem to find an example and when i view my source it seems as if the validator function is still in the onclick event.
here is the valSubmit() function.
function valSubmit()
{
var packLocalLan = document.forms[0]["packLocalLan"].value.toUpperCase();
var packUplinkWan = document.forms[0]["packUplinkWan"].value.toUpperCase();
var packBridging = document.forms[0]["packBridging"].value.toUpperCase();
var packAp = document.forms[0]["packAp"].value.toUpperCase();
var guiLocalLan = document.forms[0]["txtTestLanMacAddress"].value.toUpperCase();
var guiUplinkWan = document.forms[0]["txtTestWanMacAddress"].value.toUpperCase();
var guiBridging = document.forms[0]["txtTestWlan2MacAddress"].value.toUpperCase();
var guiAp = document.forms[0]["txtTestWlan1MacAddress"].value.toUpperCase();
if( packLocalLan == guiLocalLan &&
packUplinkWan == guiUplinkWan &&
packBridging == guiBridging &&
packAp == guiAp)
{
if(confirm('The test entry is valid. Are you sure you want to save this entry?'))
{
}
else
{
return false;
}
}
else
{
if(confirm('The packaging MAC addresses do not match the GUI MAC addresses. Would you like to save your test entry anyway?'))
{
}
else
{
return false;
}
}
}
btnSave.Attributes["onclick"] += "return valSubmit();";
I also tried:
btnSave.Attributes.Add("onclick", "return valSubmit();");
but this keeps canceling out my validators. I would like the user to click on the button, recieve the confirmation and then if there are any empty required fields to then be notified. I was reading some where that you need to read through the keys and add the new one in but i can't seem to find an example and when i view my source it seems as if the validator function is still in the onclick event.
here is the valSubmit() function.
function valSubmit()
{
var packLocalLan = document.forms[0]["packLocalLan"].value.toUpperCase();
var packUplinkWan = document.forms[0]["packUplinkWan"].value.toUpperCase();
var packBridging = document.forms[0]["packBridging"].value.toUpperCase();
var packAp = document.forms[0]["packAp"].value.toUpperCase();
var guiLocalLan = document.forms[0]["txtTestLanMacAddress"].value.toUpperCase();
var guiUplinkWan = document.forms[0]["txtTestWanMacAddress"].value.toUpperCase();
var guiBridging = document.forms[0]["txtTestWlan2MacAddress"].value.toUpperCase();
var guiAp = document.forms[0]["txtTestWlan1MacAddress"].value.toUpperCase();
if( packLocalLan == guiLocalLan &&
packUplinkWan == guiUplinkWan &&
packBridging == guiBridging &&
packAp == guiAp)
{
if(confirm('The test entry is valid. Are you sure you want to save this entry?'))
{
}
else
{
return false;
}
}
else
{
if(confirm('The packaging MAC addresses do not match the GUI MAC addresses. Would you like to save your test entry anyway?'))
{
}
else
{
return false;
}
}
}