Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Jan 2006
    Posts
    88
    Thanks
    4
    Thanked 1 Time in 1 Post

    How do i use this validation script?

    Hi,

    I'm using this http://www.javascript-coder.com/html...ml#descriptors

    I cannot figure out how to add the validation to the radio boxes! (Code Below)

    Anyone able to help out?

    Code:
    <div>
        
        <br><span class="required"><br>*</span> Previous Driving Experience<br><br>
    
        <input type="radio" name="Experience" value="none" id="Experience1_0" class="radio">
    
        No experience – new to driving!
    
      <br>
    
        <input type="radio" name="Experience" value="few" id="Experience1_1" class="radio">
    
        Had a few lessons already
    
      <br>
    
        <input type="radio" name="Experience" value="familyfriend" id="Experience1_2" class="radio">
    
        Had a bit of practice with a friend/family member
    
      <br>
    
        <input type="radio" name="Experience" value="loads" id="Experience1_3" class="radio">
    
        Had loads of lessons or failed a driving test already
    
      <br>
    
        <input type="radio" name="Experience" value="qualified" id="Experience1_4" class="radio">
    
        Qualified driver - already passed a driving test
    
      <br>
      
    </div>

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    Despite the similar sounding names, Java is not the same as Javascript.
    Moving from Java forum to Javascript forum.

  • #3
    New Coder
    Join Date
    Jan 2006
    Posts
    88
    Thanks
    4
    Thanked 1 Time in 1 Post
    Anyone help me add validation to a radio group?

  • #4
    Regular Coder low tech's Avatar
    Join Date
    Dec 2009
    Posts
    852
    Thanks
    173
    Thanked 94 Times in 94 Posts
    Hi

    When you download that js script they also provide examples -- including radio -- not sure if you noticed that.

    anyway, to me it looks like you probably need to add this


    Code:
      var chktestValidator  = new Validator("name_of_your_form_here");  
      chktestValidator.addValidation("Experience","selectradio","Please select an option from 'Experience'");

    As an example, your code will probably look something like this:


    Code:
    <script  type="text/javascript">  
    
     var frmvalidator = new Validator("name_of_your_form_here");  
    
     frmvalidator.addValidation("FirstName","req","Please enter your First Name");  
    
     frmvalidator.addValidation("FirstName","maxlen=20", "Max length for FirstName is 20");  
    
     frmvalidator.addValidation("LastName","req");  
    
     frmvalidator.addValidation("LastName","maxlen=20");
    
    var chktestValidator  = new Validator("name_of_your_form_here");  
      chktestValidator.addValidation("Experience","selectradio","Please select an option from 'Experience'");  
    
    
    </script>

    LT
    ps not tried and tested
    Last edited by low tech; 07-02-2011 at 12:16 AM.

  • Users who have thanked low tech for this post:

    reyna12 (07-03-2011)

  • #5
    New Coder
    Join Date
    Jan 2006
    Posts
    88
    Thanks
    4
    Thanked 1 Time in 1 Post
    Ahh thank you! That's what i was missing

    Code:
    var chktestValidator  = new Validator("name_of_your_form_here");

  • #6
    Regular Coder low tech's Avatar
    Join Date
    Dec 2009
    Posts
    852
    Thanks
    173
    Thanked 94 Times in 94 Posts
    Hi reyna12

    well done

    Glad that it worked out

    LT


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •