multi stage range validation - javascript

So I want to have essentially have two range validators, so there is two limits.
Ex. I have a text box that has a range validator of min. 1 and max 10 and if out of that range the value is not accepted but inside that range there is another range validator which is min. 3 and max 6 and if outside that range a messagebox pops up saying your value is out of operating range, do you still want to submit the value? It also needs to be at runtime.
Im not quite sure how to go about this, if anyone can help that would be awesome.

You might take a look at this post. You can use a CustomValidator to do what you need.
https://stackoverflow.com/questions/251842/asp-net-extended-range-validation

Related

Counting Number of Text Entry Answers on Qualtrics Survey

I am entirely new to both Qualtrics and Javascript (as such, apologies for how elementary this question may be). I have a survey on the former that will require using Javascript in a couple of the different Blocks in the survey to count the number of answers provided by a user in a number of different text entry boxes (all of which are in just one Block).
We want to pay respondents by the number of suggestions they make, so I really just want to count how many of the different text entry boxes in that one question Block have something written in them, to then use as a variable in another Block at the end of the survey to pay respondents based on how many questions they answered.
Conceptually, I assume it'll just mean initializing a counter, looping over the N text entry boxes we have, adding +1 to the counter for every one of those N boxes in which anything has been entered (I'm not worrying about whether what is entered is actually meaningful to us, assuming people don't just enter spaces), and keeping that variable to use in the very last block of the survey (where we tell them what they have earned, which is a fixed amount per suggestion). I just can't seem to find even the building blocks/ elementary syntax to implement that very simple counter through Googling and searching around here (I tried to get a bit of inspiration from these questions but no success so far: (1) Qualtrics Word Counter Javascript; (2) Qualtrics: javascript - text entry).
Any help would be appreciated!
You can do this in your survey flow after the text entry questions block:
Embedded Data: count = 0
Branch: If Text Question 1 Not Empty
Embedded Data: count = $e{ e://Field/count + 1 }
Branch: If Text Question 2 Not Empty
Embedded Data: count = $e{ e://Field/count + 1 }
etc...
At the end count will equal the number of text entry questions answered.

Consider 0 number of hits for omitted dates

In this example, I draw a chart from 4 pairs of date and number of visits. I can change dataGrouping.units to day or month with sum as approximation.
For the dates that don't appear in data, I want to consider their number of visits is 0. However, the current chart looks misleading.
One way to amend that is to prepare the data manually by myself, eg, by completing data by adding all the other dates with 0 as number of visits.
Does anyone know if HighCharts provides some parameters to customize this automatically? I tried pointInterval and pointIntervalUnit, it seems they have other purposes...
It seems that you need to set xAxis.ordinal to true.
Live demo: http://jsfiddle.net/kkulig/hujdkL1L/
API reference: https://api.highcharts.com/highstock/xAxis.ordinal

JQDateRangeSlider change bounds issue

I'm working with the DateRangeSlider for the first time and I'm using it as a TimeSlider: FiddleJS
The problem is that when a button is pressed the min bounded value, or the max one, should change, but it doesn't do anything for min or broke the slider when pressing the button for max.
The default values are for January 1st:
var minDateStr = "2014-01-01T00:00:00Z";
var maxDateStr = "2014-01-01T23:59:00Z";
to display the hours:minutes for one day and the button bounded values are from January 5th:
min :new Date("2016-01-05T05:00:00Z")
Is there a way to change the min and max bounds properly to "2016-01-05T05:00:00Z" without changing the default values (January 1st)?
I'm not sure if the task you're trying to achieve is practical or is even possible.
According to the documentation, slider values can be changed by code only at initialization. It means that even if you set either min2 or max2 to either end to the bound, then the slider can't "jump" there to properly represent the area you've originally selected. This is not practical.
Moreover, in the documentation, I couldn't find any way to get the values at which the labels are "standing". Apparently, min2 and max2 are not modified but serve rather as regular and unmodified JS constants.
You can modify the bounds but if you desire to do so, you have to use HTML inputs for dates. It doesn't seem to be possible by defining new bounds with the selected range.

Javascript rounding down

So I've looked into this for several hours before finally giving up and asking help.
I'm currently trying to form fill a character sheet for Pathfinder (D&D 3.5 equivalent) using adobe acrobat. I want to make it so when I fill in my strength score it will auto fill out anything that has to do with strength.
More specifically I need it to take my ability score divide by two and subtract 5 for my ability modifier. But when I use 17 for instance as my Strength score my modifier is 4. I need it to round down not up.
I tried to subtract 5.5 instead and that works until its 10 or lower. At which point I have the opposite problem.
My current code is Strength/2-5
Use Math.floor() like this:
var score = 17.0;
result = Math.floor((score / 2) - 5);
alert(result)
Output:
3
Original:
Strength/2-5
(it worked but it needed to round down instead of up)
Final:
var a = this.getField("Strength")
event.value = Math.floor((a.value - 10) / 2)
Thank you for trying everybody! Process of elimination gets it done

divide one value by another

I have some code from someone but wondering why they might have used a function like this.
this.viewable= 45;
getGroups: function() {
return Math.ceil( this.getList().length / this.viewable );
}
Why would they divide the list length by a number viewable.
The result is the amount of items that should be rendered on the screen.
Why not just say 45 be the number. Is it meant to be a percentage of the list. Usually I will divide a large value by a smaller value to get the percentage.
Sorry if this seems like a stupid math question but my Math skills are crap :) And just trying to understand and learn some simple Math skills.
It's returning the number of groups (pages) that are required to display the list. The reason it's declared as a variable (vs. using the constant in the formula) is so that it can be modified easily in one place. And likely this is part of a plugin for which the view length can be modified from outside, so this declaration provides a handle to it, with 45 being the default.
That will give the number of pages required to view them all.
I would guess you can fit 45 items on a page and this is calculating the number of pages.
Or something similar to that?
This would return the total number of pages.
Total items = 100 (for example)
Viewable = 45
100 / 45 = 2.22222....
Math.ceil(2.2222) = 3
Therefore 3 pages
judging by the function name "getGroups", viewable is the capacity to show items (probably some interface list size).
By doing that division we know how many pages the data is to be divided (grouped) in order to be viewed on the interface. The ceil functions guarantees that we don't left out partial pages, if we had come records left that don't fill a complete page, we still want to show them and therefor make them count for a page.

Categories