...

View Full Version : How do i use this validation script?



reyna12
06-30-2011, 02:36 PM
Hi,

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

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

Anyone able to help out?


<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>

Fou-Lu
06-30-2011, 03:19 PM
Despite the similar sounding names, Java is not the same as Javascript.
Moving from Java forum to Javascript forum.

reyna12
07-01-2011, 05:21 PM
Anyone help me add validation to a radio group?

low tech
07-02-2011, 12:06 AM
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



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:



<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:)

reyna12
07-03-2011, 04:14 PM
Ahh thank you! That's what i was missing


var chktestValidator = new Validator("name_of_your_form_here");

low tech
07-03-2011, 11:54 PM
Hi reyna12

well done

Glad that it worked out:)

LT



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum