Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I have Firstname,Lastname,Adress,TelephoneNo ...now i want to enter anyone Firstname or Lastname ...if i enter both .and click add it should not go into database...
Can anyone give someidea....

Thank You
Posted
Updated 16-Apr-15 22:27pm
v2
Comments
[no name] 17-Apr-15 4:28am    
in web or window app?
Member 11148509 17-Apr-15 4:42am    
In web
John C Rayan 17-Apr-15 4:28am    
what's the issue you are having?
Member 11148509 17-Apr-15 4:42am    
I dint get anyidea ...just need some idea to impliment

Looks like you need an 'x-or' (one or the other, not both).

As far as I know, there is no x-or operator. You have to combine or (a||b) and not and (!(a&&b))

which would look like if((a||b)&&!(a&&b)){}

so try this:
C#
bool hasFirstName = !string.IsNullOrEmpty(firstname);
bool hasLastName = !string.IsNullOrEmpty(lastname);

if ((hasFirstName || hasLastName) && !(hasFirstName && hasLastName))
{
    //insert
}
else
{
    //don't
}
 
Share this answer
 
JavaScript
var Fname=$("txtfname").val();
            Var LName= $("txtlname").val();
 

        if ((Fname!=""&& LName==""))
        {
            //insert
        }
        else if((Fname==""&& LName!=""))
        {
           //insert
        }
else{
//stop
}
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900