Click here to Skip to main content
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 21: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 George Jonsson 175
1 Kornfeld Eliyahu Peter 169
2 Zoltán Zörgő 139
3 PIEBALDconsult 130
4 OriginalGriff 120
0 OriginalGriff 6,165
1 DamithSL 4,658
2 Maciej Los 4,107
3 Kornfeld Eliyahu Peter 3,649
4 Sergey Alexandrovich Kryukov 3,342


Advertise | Privacy | Mobile
Web04 | 2.8.141220.1 | Last Updated 30 Aug 2012
Copyright © CodeProject, 1999-2014
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