Home arrow Ondersteuning arrow Forums
LimeSurvey Forums
Welcome, Guest
Please Login or Register.    Lost Password?
[done] Complexe validation (1 viewing) (1) Guest
Go to bottom Favoured: 0
TOPIC: [done] Complexe validation
#16281
LordWolfy (User)
Fresh Lemon
Posts: 6
graphgraph
User Offline Click here to see the profile of this user
[done] Complexe validation 4 Months, 1 Week ago Karma: 0  
Hello,
I see in the forum that someone wants to make a medium complex validation

(multi numeric field that the sum must be 100 because it is a percentage)

complex validation can have an easy but not user friendly solution

the idea is to had a "complex validation" field (big textarea) in wich the user can write javascript (a LOB in database)

this javscript must have a return true or false value and the code written is inserted in a function

for exemple if we wants to make a very easy validation on question17
(this is an exemple and this is perhaps not the best way to check this)

if type a validation formula in the "complex validation" field
--
if (thisForm.question17.value == 5) {
return true
} else {
return false;
}
--

because the complexe validation field is not empty during the generation
it will genereate something like


<input type="text" name="question17">
<script>
function validate_question17{
var thisForm = document.form; // This must be generated to avoid error
//From complexe validation field
if (thisForm.question17.value == 5) {
return true
} else {
return false;
}

//
}
<script>

<script>
function formSubmitFunction(
var finalResult = true;

// for each question if there is a validation function
var questionResult = validate_question17();
if (!questionResult) {
alert('question17 has not been validated';
finalResult = false;
}

return finalResult ;

}
</script>



of course this is not absolutly perfect because if the generate html (name of form or name of question change there will be javascript issue)
 
Logged Logged  
 
Last Edit: 2008/07/21 12:31 By Mazi.
  The administrator has disabled public write access.
#16388
Mazi (Moderator)
Moderator Lime
Posts: 3262
graph
User Offline Click here to see the profile of this user
Re:Complexe validation 4 Months ago Karma: 25  
Have you tried this out in a real survey?

Please mind to switch off the xss-filter when trying to use javascript:
$filterxsshtml: This setting enables filtering of suspicious html tags in survey, group, questions and answer texts in the administration interface. Only leave this to 'false' if you absolutely trust the users you created for the administration of LimeSurvey and if you want to allow these users to be able to use Javascript, Flash Movies, etc.
 
Logged Logged  
 
Best regards,
Mazi
______________________
Need help? I can: set up Limesurvey for you / create your survey / implement additional features / design your template / offer premium support -> Contact.
  The administrator has disabled public write access.
#16426
fmark (User)
Fresh Lemon
Posts: 2
graphgraph
User Offline Click here to see the profile of this user
Re:Complexe validation 4 Months ago Karma: 0  
Is this complex validation already in limesurvey, or is this a feature request?
 
Logged Logged  
  The administrator has disabled public write access.
#16441
LordWolfy (User)
Fresh Lemon
Posts: 6
graphgraph
User Offline Click here to see the profile of this user
Re:Complexe validation 4 Months ago Karma: 0  
This was a request but it looks lioke we can do it by just writing javascript in label text
 
Logged Logged  
  The administrator has disabled public write access.
Go to top