473,516 Members | 2,737 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

chechkbox list validation

19 New Member
Hi all


i have tried to validated the my textboxes and checkbox lists also,

i've write this following script



Expand|Select|Wrap|Line Numbers
  1. function validateResume()
  2. {
  3.     var FirstName = document.getElementById("txtFirstName");
  4.     var LastName = document.getElementById("txtLastName");
  5.     var Address1 = document.getElementById("txtAddress1");
  6.     var Address2 = document.getElementById("txtAddress2");
  7.     var City = document.getElementById("txtcity");
  8.     var State = document.getElementById("txtstate");
  9.     var Zip = document.getElementById("txtzip");
  10.     var DOB = document.getElementById("txtdob");
  11.     var Phone1 = document.getElementById("txtphn1");
  12.     var Phone2 = document.getElementById("txtphn2");
  13.     var Email = document.getElementById("txtemail");
  14.     var Skillset = document.getElementById("Chkskil");
  15.     var Qualification = document.getElementById("chkqualification");
  16.     var flag = 0;
  17.     if (FirstName.value == "") {
  18.         flag = 1;
  19.         document.getElementById("lblsave").innerHTML = "Please enter FirstName";
  20.         FirstName.focus();
  21.     }
  22.     else if (LastName.value == "") {
  23.         flag = 1;
  24.         document.getElementById("lblsave").innerHTML = "Please enter LastName";
  25.         LastName.focus();
  26.     }
  27.     else if (Address1.value == "") {
  28.         flag = 1;
  29.         document.getElementById("lblsave").innerHTML = "Please enter Address1";
  30.         Address1.focus();
  31.     }
  32.     else if (Address2.value == "") {
  33.         flag = 1;
  34.         document.getElementById("lblsave").innerHTML = "Please enter Address2";
  35.         Address2.focus();
  36.     }
  37.     else if (City.value == "") {
  38.         flag = 1;
  39.         document.getElementById("lblsave").innerHTML = "Please enter City";
  40.         City.focus();
  41.     }
  42.     else if (State.value == "") {
  43.         flag = 1;
  44.         document.getElementById("lblsave").innerHTML = "Please enter State";
  45.         State.focus();
  46.     }
  47.     else if (Zip.value == "") {
  48.         flag = 1;
  49.         document.getElementById("lblsave").innerHTML = "Please enter Zip";
  50.         Zip.focus();
  51.     }
  52.     else if (Zip.value.length != 6) {
  53.         flag = 1;
  54.         document.getElementById("lblsave").innerHTML = "Please Enter valid Zip ";
  55.         Zip.focus();
  56.     }
  57.     else if (DOB.value == "") {
  58.         flag = 1;
  59.         document.getElementById("lblsave").innerHTML = "Please enter DOB";
  60.         DOB.focus();
  61.     }
  62.     else if (Phone1.value == "") {
  63.         flag = 1;
  64.         document.getElementById("lblsave").innerHTML = "Please enter Phone1";
  65.         Phone1.focus();
  66.     }
  67.     else if (Phone1.value.length != 10) {
  68.         flag = 1;
  69.         document.getElementById("lblsave").innerHTML = "Please Enter Valid Phone1";
  70.             Phone1.focus();
  71.     }
  72.     else if (Phone2.value.length == "") {
  73.         flag = 1;
  74.         document.getElementById("lblsave").innerHTML = "Please Enter enter Phone2";
  75.         Phone2.focus();
  76.     }
  77.     else if (Phone2.value.length !=10) {
  78.         flag = 1;
  79.         document.getElementById("lblsave").innerHTML = "Please Enter Valid Phone2";
  80.             Phone2.focus();
  81.     }
  82.     else if (Email.value == "") {
  83.         flag = 1;
  84.         document.getElementById("lblsave").innerHTML = "Please enter email";
  85.         Email.focus();
  86.     }
  87.     else if (checkcontact(Email.value) == false) {
  88.         flag = 1;
  89.         document.getElementById("lblsave").innerHTML = "Please enter valid e-mail";
  90.         Email.focus();
  91.     }
  92.     else if (document.getElementById('FileUpload1').value.trim() == "") {
  93.        flag = 1;
  94.        document.getElementById('lblsave').innerHTML = "Browse a Document";
  95.        if (hdnSecretValue.value > 0)
  96.         {
  97.            document.getElementById('lblsave').style.display = 'none';
  98.           return true;
  99.         }
  100.     }
  101.     else if (Skillset=='0') {
  102.         flag = 1;
  103.    var test = Skillset.getElementsByTagName("input").length;
  104.     var count = 0;
  105.     for (var i = 0; i < test; i++) {
  106.         if (test[i].checked) {
  107.             count = 1;
  108.         }
  109.     }
  110.     if (count == 0) {
  111.         document.getElementById('lblsave').innerText = "Select Users!";
  112.         return false;
  113.     }
  114. }
  115.     else if (Qualification == '0') {
  116.         flag = 1;
  117.         var test2 = Qualification.getElementsByTagName("input").length;
  118.         var count = 0;
  119.         for (var i = 0; i < test; i++) {
  120.             if (test2[i].checked) {
  121.                 count = 1;
  122.             }
  123.         }
  124.         if (count == 0) {
  125.             document.getElementById('lblsave').innerText = "Select Users!";
  126.             return false;
  127.         }
  128.     }
  129.     if (flag == 0) {
  130.         return true;
  131.     }
  132.     else {
  133.         $('#divErrormsg').fadeIn(2000);
  134.         return false;
  135.     }
  136. }
  137.  

All the text box fields are working fine, but the chechkbox list are does not work, i've tried in many ways, i don't know what i'm doing wrong.. can someone help me with this?..
Oct 7 '16 #1
2 1172
Dormilich
8,658 Recognized Expert Moderator Expert
i don't know what i'm doing wrong
you treat integers as a list.
var test = Skillset.getElementsByTagName("input").length;
Oct 7 '16 #2
christyjs
19 New Member
It is a string..


Thanks
Oct 7 '16 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
4018
by: shihabca | last post by:
how to validate a radiolist for being left unchecked, using javascript
3
2046
by: msnews.microsoft.com | last post by:
Hi All, I m facing problem in Server Side Validation. For Example The Scenario is I have two fields on the page 1 Country Dropdown List 2 Province Textbox 3 State Dropdown List
1
1375
by: effendi | last post by:
Can anyone share how we could validate a Selection List in IE ensuring user selects only 1 entry? Thanks
27
4681
by: Chris | last post by:
Hi, I have a form for uploading documents and inserting the data into a mysql db. I would like to validate the form. I have tried a couple of Javascript form validation functions, but it appears that the data goes straight to the processing page, rather than the javascript seeing if data is missing and popping up an alert. I thought it...
4
1430
by: AMBLY | last post by:
Hi Hope you can help me with this I run Access2000 on XP Form has 3 fields: cboSTATUS - which can be set via Limited value List A B or Complete. Default is set as A. cboTHIS - which can be set via Limited Value List X, Y or Z. No Default. Intiially field in blank (Null). txtTHAT - which can be anything. No Default text. Intiially...
2
2178
by: msch.prv | last post by:
Is there a specific method to disable field validators in a user control.from within a parent page or does it require an ad hoc approach? The page attribute ValidateRequest does not seem to be available in user controls. TIA for any inputs.
8
2721
by: Bryan | last post by:
I want my business objects to be able to do this: class Person(base): def __init__(self): self.name = None @base.validator def validate_name(self): if not self.name: return
3
2089
pradeepjain
by: pradeepjain | last post by:
hii guys , I wanna share a very gud ajax validation script with php... Ajax Form Validation - sForm | chains.ch weblog I am very new to ajax .So i wanna small help....i want to improve that script with adding checkbox,radiobutton validation and dropdown list validation . but i am not able to do it.....any one can add his/her...
1
1370
by: ahilar12 | last post by:
hi experts <head> <script type="text/javascript"> </script> </head> <body> <form> <select name="team" id="mylist" > <option></option> <option>north</option>
9
3179
by: ahilar12 | last post by:
1. <head> 2. <script type="text/javascript"> 3. </script> 4. </head> 5. <body> 6. <form> 7. <select name="team" id="mylist" > 8. <option></option> 9. <option>north</option> 10. <option>south</option>
0
7276
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7182
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7408
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7581
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7142
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7548
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5714
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5110
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
488
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.