Community / Forums » My · Videos · Forums · Wiki ·
Community Forums
When adding posts that require attachments, select the Community Forums folder to upload new files.
 
ForumForumCoreCoreGeneralGeneralInput Radio control Required ValidationInput Radio control Required Validation
Previous Previous
 
Next Next
New Post
 7/24/2010 9:15 AM
 

Is it possible to have Input Radio control Required Validation using OWS validation library?

New Post
 7/27/2010 8:21 AM
 

Still i am not able to implement the Input Radio control Required Validation. The situation is like that i have one question and there are several options for that question.

Example:

<!-- question -->
<p><strong>Are you interested in an alarm system for a business or residential location?</strong><br />
This field is required.</p>
<div>
<input name="802000" value="Residential" {IIF,"'[BusRes,S]'='Residential'","CHECKED",""} id="802000" type="radio" />
<label for="1">Residential</label>
<br />
<input name="802000" value="Business" {IIF,"'[BusRes,S]'='Business'","CHECKED",""} id="802000" type="radio" />
<label for="2">Business</label>
</div>
<span
id="ques1"
controltovalidate="802000"
errormessage="Select Location."
display="Dynamic"
evaluationfunction="RequiredFieldValidatorEvaluateIsValid"
initialvalue=""
group="step1"
style="color:Red;display:none;">*</span>
<br/>

<a onclick="if (typeof(Page_SmartValidate) == 'function') return Page_SmartValidate('step1');" language="javascript"
href=" ows.Fetch([*moduleid],0,'Next=2');"><img border="0" src="/images/next-icon.jpg" alt="Next" /></a>

This code is passed, even if I do not select any radio button option. I want to force user to Select ATLEAST 1 radio option. How can I do so?

New Post
 7/27/2010 2:19 PM
 

here is an example fo how to do radio button validation

removed the script tags from the module header section and added spaced to the span tag to ensure that the code displays inthe forum properly

<s p a n id="val_branch" controltovalidate="frm_branchId" errormessage="Branch is a required field." display="Dynamic" clientvalidationfunction = "validRadio"
evaluationfunction="CustomValidatorEvaluateIsValid" initialvalue="" style="color:Red;font-size:24px;"> <img src="[ApplicationPath,system]/images/required.gif"></s p a n>
function validRadio(val, args)
{var radio_choice = false;
var chks = document.getElementsByName('frm_branchId');
for (counter=0; counter < chks.length; counter++) {
if (chks[counter].checked)
radio_choice = true;
}
if (!radio_choice) {
args.IsValid = false;
}
else {
args.IsValid = true;
}
}
New Post
 7/28/2010 4:14 AM
 

Thanks that worked great! But can you tell me if this function I've to create for each control ? I've around 10-12 radio groups and your radio function as hard coded "getElementByName('namevalue')" statement. Do i have to create new function for each group of radio buttonsor can i automate this statement?

New Post
 7/29/2010 4:45 AM
 
 Modified By satish  on 7/29/2010 4:46:39 AM

i have written the code for Multiple Radio Groups. Which is :

On Cntrol Header:

<script type="text/javascript">
function validRadio(val, args){
var radio_choice = false;
var chks = document.getElementsByName(val.controltovalidate);
for (counter=0; counter < chks.length; counter++) {
if (chks[counter].checked)
radio_choice = true;
}
args.IsValid = radio_choice;
}

In Your From HTML:

<span id="ques6"
controltovalidate="804016"
errormessage="Select Estimated Budget."
display="Dynamic"
clientvalidationfunction="validRadio"
evaluationfunction="CustomValidatorEvaluateIsValid"
initialvalue=""
group="step4"
style="color:Red;font-size:24px;">
</span>

Previous Previous
 
Next Next
ForumForumCoreCoreGeneralGeneralInput Radio control Required ValidationInput Radio control Required Validation