How Do I make I make this validation work?

Hi

I have a textbox that is for email. I want to make sure that something has been entered in it. The thing is though an email address is optional on my form until the user clicks click the radio button(that represents "Do you want a email response").

So I don't think I can stick a required field validator on that area since it will always go off. I tried to make a custom validtor but that did not work too well since it seems to get activated once you click on the textbox and start typeing away and then leave that box.

So I am not sure how I could make it check this. I am doing the client side validation. The server side should be no problem since I can go back to the server and then check if the radio button was checked and if the textbox was left blank. Its just how to do it on the client side with javascript?


Ms Sql 2005, VS 2008 SP1, Windows XP Pro.
0
chobo2
7/2/2008 8:10:07 AM
asp.net.getting-started 91979 articles. 4 followers. Follow

4 Replies
693 Views

Similar Articles

[PageSpeed] 12

Use a custom validator. In the custom validator check if the radio button is selected then only check for value is text box. and based on this set the custom validator to valid of invalid...


Vikram
www.vikramlakhotia.com


Please mark the answer if it helped you
0
vik20000in
7/2/2008 8:44:54 AM

 hi so from what i understood you want to check on the client side if a textbox is empty and if a radio button is checked

 

var myTextBoxObj =  document.getElementById('<%= myTextBox.ClientID %>');

 var RdbObj = document.getElementById('<%= Rdb.ClientID %>');

 

if( (myTextBoxObj  != null) && (RdbObj  != null))

 {

    if(myTextBoxObj.value == "")

    {

          alert("EMPTY TEXTBOX");

   }

  if(RdbObj.checked ==  true)

 {

    alert("CHECKED");
 

}

else

 {

   alert("NOT CHECKED");
 

}
 


The Things That doesnot kill you make, you stronger
0
lallouna85
7/2/2008 9:55:25 AM

lallouna85:

 hi so from what i understood you want to check on the client side if a textbox is empty and if a radio button is checked

 

var myTextBoxObj =  document.getElementById('<%= myTextBox.ClientID %>');

 var RdbObj = document.getElementById('<%= Rdb.ClientID %>');

 

if( (myTextBoxObj  != null) && (RdbObj  != null))

 {

    if(myTextBoxObj.value == "")

    {

          alert("EMPTY TEXTBOX");

   }

  if(RdbObj.checked ==  true)

 {

    alert("CHECKED");
 

}

else

 {

   alert("NOT CHECKED");
 

}
 

 

 

So in the custom validate do I set it to validate a control? Like I tried setting to validate the radio button but that did not work.


Ms Sql 2005, VS 2008 SP1, Windows XP Pro.
0
chobo2
7/2/2008 8:53:43 PM

Hi,

The RadioButton control cannot be validated by ASP.NET Validation Controls.

You can use JavaScript to validate it to see if it is checked in the Client. For example:

<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

    protected void Page_Load(object sender, EventArgs e)
    {

    }


    protected void Button1_Click(object sender, EventArgs e)
    {

    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>

    <script type="text/javascript">
     function ValidateRadio()
     {
             var RdbObj = document.getElementById('<%= RadioButton1.ClientID %>');

             if(RdbObj.checked)
             {
                alert("CHECKED");
                return true;
             } 
            else 
             {
               alert("NOT CHECKED");
               return false;
             }
     }

    </script>

</head>
<body>
    <form id="form1" runat="server">
    <div>
    </div>
    <asp:RadioButton ID="RadioButton1" runat="server" Text="Do you want a email response" />
    <br />
    <br />
    <asp:Button ID="Button1" runat="server" Text="Validate" OnClick="Button1_Click" OnClientClick="return ValidateRadio();" />
    </form>
</body>
</html>

 

I hope this helps.


Thomas Sun
Microsoft Online Community Support

Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question.
0
Thomas
7/7/2008 6:00:40 AM
Reply:

Similar Artilces:

Making should be make
Name: Scott Melton Email: scott_rides_againatyahoodotcom Product: Firefox Summary: Making should be make Comments: The opening page for Bugzilla is poorly worded. http://www.mozilla.org/projects/seamonkey/start/ The second line: If you want to help making this application even better, we would encourage you to take part in the should be MAKE, not MAKING Browser Details: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.2) Gecko/20070222 SeaMonkey/1.1.1 ...

HELP, cannot make getting started examples work
Help pls, I have MS Windows XP PRO, NET Framework 1.1 and SDK 1.1, SQL Server and IIS 5.1 installed...I think I have everything I need to make them work but I cannot do it. In particular I cannot run the examples on Web Forms, I suppose the ones which connect to databases. I alway get the same error. For example, when I run the example Intro7.aspx I get this error: Errore server nell'applicazione '/QuickStart/aspplus/samples'. -------------------------------------------------------------------------------- Errore del parser Descrizione: Errore durante l'analisi di una risorsa ne...

Make Porting/expand-macro.pl work with a make other than `make`, also Win32 compatibility fixes
--------------040507080907060101050501 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit Hello, recently it came to my attention that `Porting/expand-macro.pl` does not work if your `make` tool is named anything other than `make`. The first attached patch changes it so that it loads Config.pm and uses the configured $Config{make} from there. I presume that anybody running `Porting/expand-macro.pl` also knows about how to give `perl` the appropriate Config.pm resp. how to invoke the proper Perl. The second patch assumes that `Porti...

superreview granted: [Bug 334478] Get suiterunner to actually run (start up a somewhat usable browser window) : [Attachment 219302] make help locale work
neil@parkwaycc.co.uk <neil@httl.net> has granted Robert Kaiser <kairo@kairo.at>'s request for superreview: Bug 334478: Get suiterunner to actually run (start up a somewhat usable browser window) https://bugzilla.mozilla.org/show_bug.cgi?id=334478 Attachment 219302: make help locale work https://bugzilla.mozilla.org/attachment.cgi?id=219302&action=edit ------- Additional Comments from neil@parkwaycc.co.uk <neil@httl.net> Somewhat annoying, but at least it doesn't seem to conflict with symlinked chrome. ...

superreview requested: [Bug 334478] Get suiterunner to actually run (start up a somewhat usable browser window) : [Attachment 219302] make help locale work
Robert Kaiser <kairo@kairo.at> has asked neil@parkwaycc.co.uk <neil@httl.net> for superreview: Bug 334478: Get suiterunner to actually run (start up a somewhat usable browser window) https://bugzilla.mozilla.org/show_bug.cgi?id=334478 Attachment 219302: make help locale work https://bugzilla.mozilla.org/attachment.cgi?id=219302&action=edit ------- Additional Comments from Robert Kaiser <kairo@kairo.at> toolkit packages its own help locale files into the locale .jar, and that interferes with extensions/help filling up help locale. This patch fixes help by o...

keeps making me download update, but, update doesn't work, makes me download update, update doesn't work..................
Name: donald davis Email: galenachefatyahoodotcom Product: Firefox Summary: keeps making me download update, but, update doesn't work, makes me download update, update doesn't work.................. Comments: That's pretty much the whole deal. An update screen pops up, I update, the update doesn't take and the next time I use firefox mozilla the same thing happens over and over and over. Thanks Browser Details: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.4 ...

[PATCH] make C< make parrot > work
The instructions say to run "make parrot", but that won't work because Configure.pl tells Makefile.in that the test program's name is 'test_parrot'. This tiny patch fixes that nit. diff -r -u parrot/Configure.pl parrot-andy/Configure.pl --- parrot/Configure.pl Fri Dec 14 20:39:40 2001 +++ parrot-andy/Configure.pl Tue Dec 18 13:31:08 2001 @@ -84,7 +84,7 @@ ld_debug => '', # include debug info in executable perl => $^X, - test_prog => 'test_parrot' . $Config{_exe}, + test_prog => 'parrot' . $Config{_exe},...

make validators work only on specific butttons
I have textboxes with validators in a web form. I want the validators to check input only when I press buttonA. I want buttonB to transfer me to another form even if the validators find input errors. How? Hi, Try : CausesValidation=False <asp:Button CausesValidation=False id="ButtonB" runat="server" Text="Button"></asp:Button> HTH K B ShajudeenAreYaar.comDubai, United Arab Emirates. Thanks, it worked! I changed this button property in the designer....

Help, cannot make the quick start examples work
I cannot make the examples work in any way. I have Windows XP PRO, SQL server 2000, IIS, Net Framework and SDK installed but they dont work. For example, in the example n. 7 of the web forms i get this error, and so on with the other examples: Errore server nell'applicazione '/QuickStart/aspplus/samples'. -------------------------------------------------------------------------------- Errore del parser Descrizione: Errore durante l'analisi di una risorsa necessaria per soddisfare la richiesta. Rivedere i dettagli relativi all'errore e modificare in modo appropriato il codice sor...

What would I need to do here to make this work in .net 2.0?
Hi there (really stumped this time).. I have a page with a search facilty that when submitted populates a Datagrid and displays it.  Works great in .net 1.x  what (other than create the sql server connection) would be beeded to .net 2.0. I use VSE and SQL Server 2005. Existing code: <script runat="server">     Function FindByTitle(ByVal search As String) As System.Data.DataSet            Dim connectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0; Ole DB Services=-4; Data Source=e:\domains\windm...

How to make validation methods to work for international characters
Hi, I have a validation method called isString(string S) public static Boolean isString(string S)  {System.Text.RegularExpressions.Regex test = new System.Text.RegularExpressions.Regex("[^a-zA-Z]"); return test.IsMatch(S); } How will I modify this method to accomodate international characters. For example what if I pass chinese text as input to this method? currently it returns false for anything that is not english .But I want to make this method work correcly even for non english languages.  I appreciate if ayone can provide me a way to do this. Thank you. Y...

How to make .net 2.0 image map work?
I have the following code on a (master) page: <script runat="server"> Protected Sub ImageMap1_Click(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ImageMapEventArgs) End Sub </script> <asp:ImageMap ID="ImageMap1" runat="server" Width="240px" Height="164px" ImageUrl="~/Images/door.jpg" HotSpotMode="Navigate" OnClick="ImageMap1_Click"> <asp:CircleHotSpot HotSpotMode="Navigate" Radius="25" X="180" Y="420" NavigateUrl="special.aspx" /> <asp:RectangleHotSpot HotSpotMode="Navigate" Bottom="473" Left="185" Right="140" Top="350" Altern...

Have to use DEBUG 1 to make Net::LDAPS work??
I have a password reset app written in perl; it uses CGI.pm and Net::LDAP with %args and settings for talking to Sun ONE LDAP over SSL. When I set debug => '1' in %args, he binds ok, performs search, finds entry, modifies password, and displays the appropriate next page -- albeit with lots of debug messages. But when I set debug => '0', the bind works but remaining ops fail, and I get Server Error (see error log) #------------ web server log -------------------------------------- [16/May/2006:11:37:25] failure ( 6822): for host 20.6.25.155 trying to POST /...

can't make a validator working on a popup
Hi I open a popup with window.open(). This popup display a page with a textbox and a validator. The Save button has CauseValidation to true. I also add a code like this mySaveButton.Attributes.Add("onclick","window.close();"); to close the page when I click on save. The problem is that the validator does not block the closing if its condition is wrong. This is because the page is render like this: onclick="window.close();if (typeof(Page_ClientValidate) == 'function') Page_ClientValidate(); " Is there any way to add window.close() AFTER Page_ClientValidate call? th...

How to make validation controls work for non-IE browsers?
I found validation controls are easy to use. They do make the application more robust. However, they only work on IE browser. There are still 20 to 25% of users who are not using IE (Netscape Navigator browser and etc.) Some validations are good to have while others are necessary. We can’t leave the 20-25% users behind. Or we have to code another set of validation for these 20-25% of users. If so, what good is ASP.NET? Does Microsoft deliberately leave out other browsers or there is some technical difficulties? Does anyone know the solution to make all validation controls work for ...

(1) Making Outpost work (2) Should I get rid of it?
I am on XP Pro + SP1 and have taken out a trial of Outpost Pro 2.5. I am finding it quite hard configuring this firewall. At the moment my Opera browser gets blocked whenever my third-party clipboard manager (Yankee Clipper) pastes a URL into the address bar. Outpost complains about the clipboard utility trying to change a component of the browser. Huh? I don't understand it and what's worse I don't know how to prevent Outpost blocking the browser at that point. Can anyone advise please. --- On a broader scale, is it worth peristing with Outpost? It seems...

[ID 20020325.001] make -j && make test doesn't work
[reposting with the fixed subject] This is a bug report for perl from stas@stason.org, generated with the help of perlbug 1.33 running under perl v5.7.3. ----------------------------------------------------------------- If I'm trying to build bleadperl with 'make -j' on an smp kernel (dual proc) it has some minor failures unaffecting the tests, but this prevents one from being able to say: make -j && make test since 'make test' won't run. here are all the relevant Error reports from make (the whole log is 170k). If I'm not mistaken...

VN.Net 2003 can make data connection, can't make server connection
Hi, I am using Visual Studio .net 2003 I have 2 machines, one WinXP with VS.Net and the other, Win2K Pro with SQL Server 2000 In VS.Net I can make a data connection to the SQL Server using the computer name of the SQL Server machine, however I can't make a Server connection to the same machine. Both machines are in a private network (192.168.1.x IPs) inside a firewall, with no firewall settings on either machine. Also, I have installed NetBeui on the XP machine. When I try to connect via the ip addressesm get an error saying that the IP address is outside the local network...

Make it work!
Name: Chris Email: techsaltatgmaildotcom Product: Firefox Summary: Make it work! Comments: Please make Redshift work with Firefox 3 Beta. Please! Browser Details: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9b5) Gecko/2008032620 Firefox/3.0b5 From URL: http://hendrix.mozilla.org/ ...

make ok / make nok
Shouldn't 'make ok' and 'make nok' also try to find out the version of the C compiler used if it's not gcc. Some examples: HP-UX: swlist -l bundle | grep B3901BA 11.00: B3901BA B.11.01.07 HP C/ANSI C Developer's Bundle for HP-UX 11.00 (S800) 10.20: B3901BA B.10.20.14 HP C/ANSI C Developer's Bundle for HP-UX 10.20 (S800) AIX: lslpp -L | grep 'C for AIX' 4.3.2: vac.C 4.4.0.2 C C for AIX Compiler 4.2.1: xlC.C 3.1.4.0 C C for AIX Compiler OSF/1: setld -i | grep ^OSFCMPLRS; cc -V | head -3 OSFCMPLRS425 instal...

How to make this work?
I have been looking at this post: http://forums.iis.net/t/1153995.aspx and is there any way to make it work without using a thread on its own, as the poster says, with async calls? Newbie here so would really like some info, or perhaps a few examples? Pointers to other articles or posts please?  Google does not return much for me! Many thanks, Compactor (newbie!)  What are you trying to do?Do you have local administrator access to your server? Don't forget to click "Mark as Answer" on the post that helped you.This credits that member, earns you a point and ma...

How do i make this work
 How do i make this stop giving me an error in asp.net. Code: Line 99: ' output the folder listLine 100:''''''''''''''''''''''''''''''''''''''''Line 101:objCollection As New objFolder.SubFoldersLine 102:For Each objItem in objCollectionLine 103:strName = objItem.Name --- error Description: An error occurred during the compilation of a resource required to service this request. Please review the...

make not working
I am installing a copy of fahmon for my folding rig and the install instructions say run the configure program then make and make install. The configuration goes ok, but make doesnt work. Im still teaching myself linux and im sure that im missing something. -- jcharlesr75 ------------------------------------------------------------------------ [QUOTE=jcharlesr75] I am installing a copy of fahmon for my folding rig and the install instructions say run the configure program then make and make install. The configuration goes ok, but make doesnt work. Im still teaching m...

Making make depend easy
Autrijus, I'd like for it to be easy for a Makefile to know all the dependencies of a pp-generated executable, since mine depends on a large number of locally maintained .pm files. I just modified pp by adding a new option which then results in this code being executed right after the call to Module::ScanDeps (I named the option -m after gcc's -M, since -M was already taken for pp, but probably --depend would be better): if ($Options->{m}) { print join(" \\\n\t", map($map{$_}{file}, keys %map))."\n"; exit 0; } I then pu...

Web resources about - How Do I make I make this validation work? - asp.net.getting-started

Cross-validation (statistics) - Wikipedia, the free encyclopedia
is a model validation technique for assessing how the results of a statistical analysis will generalize to an independent data set. It is mainly ...

Serena Williams eyes history, Caroline Wozniacki craves validation in women's US Open final
As Serena Williams eyes another slice of tennis history, Caroline Wozniacki is craving validation with a watershed US Open final triumph on Sunday ...

Travers Duncan asks High Court to strike down ICAC validation laws
ICAC could be sent back to the High Court as a challenge to new laws validating corruption findings looms.

Adam Scott proclaims Texas win as validation of No.1 ranking
... No.1 golfer, beating American Jason Dufner in the third hole of a play-off at the Colonial event. "It's a good feeling and maybe some validation ...

Hollande to sign gay marriage bill after Constitutional Council's validation
Hollande to sign gay marriage bill after Constitutional Council's validation People's Daily Online ... 26, 27, 28, 29, 30, 31. Jan, Feb, Mar, ...

Marketers, Get Ready for the 'Validation Era'
The public brands included has been engaging in a "friends" arms race. But there are signs that we know we overdid it.

Validation and Uncertainty
What an extraordinary conversation I had recently on Twitter. It started with Neil Killick’s statement that we should not consider our stories ...

Nvidia Icera 410 LTE Modem Passes AT&T Network Validation
... Today's news is a small step and logical precursor toward both goals, Nvidia's Icera 410 LTE and HSPA+ baseband has passed AT&T's network validation ...

Ting’s Q1 Subscriber Growth Suffers from Sprint’s New Unlocking Validation Process
Back in February, Sprint updated the process it uses to validate unlocked devices that customers want to utilize on other carriers or one of ...

[Android M Feature Spotlight] Stricter APK Validation Now Actually Checks If All Of An APK's Files Are ...
While you might file this one under "really? We weren't doing this already?" if you're a security expert, Google has added stricter validation ...

Resources last updated: 2/19/2016 10:12:33 PM