Click here to Skip to main content
11,705,763 members (54,416 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Java script
var fname = document.getElementById('<%=txtFName.ClientID%>').value;
           var dob = document.getElementById('<%=txtDob.ClientID%>').value;
           var mail = document.getElementById('<%=txtMail.ClientID%>').value;
           var web = document.getElementById('<%=txtWebsite.ClientID%>').value;
           var phone = document.getElementById('<%=txtPhone.ClientID%>').value;
           var salary = document.getElementById('<%=txtSalary.ClientID%>').value;
           var department = document.getElementById('<%=drpDepart.ClientID%>').value
           var branch = document.getElementById('<%=drbBranch.ClientID%>').value
           var error = "";
           if (fname == "" && dob == "" && mail == "" && web == "" && phone == "") {
 
               error = "Please Enter Following Details:";
 
               if (fname == "") {
                   error += "\n Enter Employee FirstName.";
               }
               if (dob == "") {
                   error += "\n Enter Employee Date Of Birth.";
               }
               if (mail == "") {
                   error += "\n Enter Employee Email.";
               }
               if (web == "") {
                   error += "\n Enter Employee Website.";
               }
               if (salary == "") {
                   error += "\n Enter Employee Salary.";
               }
               if (department == "--Select--") {
                   error += "\n Select Employee Department.";
               }
               if (branch == "--Select--") {
                   error += "\n Select Employee Branch.";
               }
               alert(error);
           }
           else {
               return true;
 
           }
i am enter FNAME text box but didn't show error what can i do any help me!!!!!
Posted 29-Aug-12 20:45pm
Comments
Timberbird at 30-Aug-12 2:58am
   
Calm down. Bugs are way too common to get excited every time you get one. First, what is your problem? "I am enter FNAME text box but didn't show error" looks like valid logic. If you didn't enter fname, that's another thing. First, are you sure you need "&&", not "||"? Second, you could consider adding "return false;" explicitly.
Providing more information would help us to understand the situation better

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

hey change you condition like below code:
if (fname == "" || dob == "" || mail == "" || web == "" || phone == "") {
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 213
1 Sergey Alexandrovich Kryukov 170
2 Inimicos 60
3 ProgramFOX 50
4 Richard MacCutchan 45
0 OriginalGriff 9,053
1 Sergey Alexandrovich Kryukov 8,347
2 CPallini 5,189
3 Maciej Los 4,726
4 Mika Wendelius 3,626


Advertise | Privacy | Mobile
Web03 | 2.8.150819.1 | Last Updated 30 Aug 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100