![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Having a bit of a problem here, wondering if anyone else has run into this. I am running two custom validators on a page. The page is used to input/edit information about devices for the company I work for. Each device may or may not have a device number associated with it, depending on its phase of development or deployment. If it does, the device number may have one of many different prefixes assigned to it, depending on the department. The first custom validator checks to see if a device prefix has been selected or if the user indicates there is no number yet. If a prefix is selected, it checks the textbox that contains the actual number. If the textbox is empty, it returns an .isValid = false and the validation summary displays the message. This works just fine. The second validator checks to see if a number was provided in the textbox. If yes, then it checks the dropdownlist to see if a prefix was selected. If not, it returns an .isValid = false to indicate the user has forgotten to assign a prefix. Here is the problem. The second custom validator returns a false, but it is not picked up by the validation summary. I've run the debugger on the script and know the false is returned. I even put alert windows into the javascript routine (old school...heh heh) to show the values being returned. The script functions correctly, but the summary will not pick it up. Here are the clips from my code: Custom Validator: asp:CustomValidator ID="validCustomDvcPrefix" runat="server" ClientValidationFunction="validateDvcNum" Display="None" ErrorMessage="You provided a device number, but failed to select a device number prefix." ValidationGroup="inputDvcLogistic"></asp:CustomValidator Javascript Routine validateDvcNum function validateDvcNum(val, args){ var txtLength = document.getElementById('<%= txtDvcNumber.ClientID %>').value.length; if (txtLength > 0){ var selectedValue = document.getElementById('<%= ddlDvcNumber.ClientID %>').options.value; if (selectedValue == 7) { args.isValid = false; alert(args.isValid + " = false"); } else { args.isValid = true; alert(args.isValid + " = true"); } } } In the routine for the var txtLength I've used both the args.Value.length and the one shown above. Each returns the correct information. I left the alerts in the code to show what I was talking about. When I select the None selection in the dropdownlist, the value it returns is 7, which is correct. Sidenote, I can't combine the validation routines, I need two seperate validators because I need specific messages based on the checks. Anyone else seen this before or have any suggestions? Would really appreciate it! Thanks in advance. |
#3
| |||
| |||
|
|
Having a bit of a problem here, wondering if anyone else has run into this. I am running two custom validators on a page. The page is used to input/edit information about devices for the company I work for. Each device may or may not have a device number associated with it, depending on its phase of development or deployment. If it does, the device number may have one of many different prefixes assigned to it, depending on the department. The first custom validator checks to see if a device prefix has been selected or if the user indicates there is no number yet. If a prefix is selected, it checks the textbox that contains the actual number. If the textbox is empty, it returns an .isValid = false and the validation summary displays the message. This works just fine. The second validator checks to see if a number was provided in the textbox. If yes, then it checks the dropdownlist to see if a prefix was selected. If not, it returns an .isValid = false to indicate the user has forgotten to assign a prefix. Here is the problem. The second custom validator returns a false, but it is not picked up by the validation summary. I've run the debugger on the script and know the false is returned. I even put alert windows into the javascript routine (old school...heh heh) to show the values being returned. The script functions correctly, but the summary will not pick it up. Here are the clips from my code: Custom Validator: asp:CustomValidator ID="validCustomDvcPrefix" runat="server" ClientValidationFunction="validateDvcNum" Display="None" ErrorMessage="You provided a device number, but failed to select a device number prefix." ValidationGroup="inputDvcLogistic"></asp:CustomValidator Javascript Routine validateDvcNum function validateDvcNum(val, args){ var txtLength = document.getElementById('<%= txtDvcNumber.ClientID %>').value.length; if (txtLength > 0){ var selectedValue = document.getElementById('<%= ddlDvcNumber.ClientID %>').options.value; if (selectedValue == 7) { args.isValid = false; alert(args.isValid + " = false"); } else { args.isValid = true; alert(args.isValid + " = true"); } } } In the routine for the var txtLength I've used both the args.Value.length and the one shown above. Each returns the correct information. I left the alerts in the code to show what I was talking about. When I select the None selection in the dropdownlist, the value it returns is 7, which is correct. Sidenote, I can't combine the validation routines, I need two seperate validators because I need specific messages based on the checks. Anyone else seen this before or have any suggestions? Would really appreciate it! Thanks in advance. |
#4
| |||
| |||
|
|
for some obscure reason, the group that wrote the webforms library, unlike the ajax group, broke with javascript standards and start their property names with an uppercase letter. so its args.IsValid -- bruce (sqlwork.com) "DJ" wrote: Having a bit of a problem here, wondering if anyone else has run into this. I am running two custom validators on a page. The page is used to input/edit information about devices for the company I work for. Each device may or may not have a device number associated with it, depending on its phase of development or deployment. If it does, the device number may have one of many different prefixes assigned to it, depending on the department. The first custom validator checks to see if a device prefix has been selected or if the user indicates there is no number yet. If a prefix is selected, it checks the textbox that contains the actual number. If the textbox is empty, it returns an .isValid = false and the validation summary displays the message. This works just fine. The second validator checks to see if a number was provided in the textbox. If yes, then it checks the dropdownlist to see if a prefix was selected. If not, it returns an .isValid = false to indicate the user has forgotten to assign a prefix. Here is the problem. The second custom validator returns a false, but it is not picked up by the validation summary. I've run the debugger on the script and know the false is returned. I even put alert windows into the javascript routine (old school...heh heh) to show the values being returned. The script functions correctly, but the summary will not pick it up. Here are the clips from my code: Custom Validator: asp:CustomValidator ID="validCustomDvcPrefix" runat="server" ClientValidationFunction="validateDvcNum" Display="None" ErrorMessage="You provided a device number, but failed to select a device number prefix." ValidationGroup="inputDvcLogistic"></asp:CustomValidator Javascript Routine validateDvcNum function validateDvcNum(val, args){ var txtLength = document.getElementById('<%= txtDvcNumber.ClientID %>').value.length; if (txtLength > 0){ var selectedValue = document.getElementById('<%= ddlDvcNumber.ClientID %>').options.value; if (selectedValue == 7) { args.isValid = false; alert(args.isValid + " = false"); } else { args.isValid = true; alert(args.isValid + " = true"); } } } In the routine for the var txtLength I've used both the args.Value.length and the one shown above. Each returns the correct information. I left the alerts in the code to show what I was talking about. When I select the None selection in the dropdownlist, the value it returns is 7, which is correct. Sidenote, I can't combine the validation routines, I need two seperate validators because I need specific messages based on the checks. Anyone else seen this before or have any suggestions? Would really appreciate it! Thanks in advance. |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |