lundi 7 août 2017

Validate a field's value if greater than another field's value in jQuery

I am a begginer in jQuery could you help me build a script for this?

I have set's of fieldset which have set of input

<p><input type="radio" class="scenarioRadio" value="5" name="group26" /><label>Strongly agree </label></p>
<p><input type="radio" class="scenarioRadio" value="4" name="group26" /><label>Somewhat agree </label></p>
<p><input type="radio" class="scenarioRadio" value="3" name="group26" /><label>Neither agree or disagree</label></p>
<p><input type="radio" class="scenarioRadio" value="2" name="group26" /><label>Somewhat disagree</label></p>
<p><input type="radio" class="scenarioRadio" value="1" name="group26" /><label>Strongly disagree </label></p>
<p><input type="radio" class="scenarioRadio" value="0" name="group26" /><label>Don’t know / Can’t say</label>

Now I have set of conditions:

  1. If two responses have equal numbers and they are next to each other, display the lower value response.

Ex.

1st user answer: Strongly agree [value="5"]
2nd user answer: Somewhat agree [value="4"]
Final answer should be the lower rank: Somewhat agree [value="4"]

  1. If two responses have equal numbers but are not next to each other, display "Don't know / Can't say"

Ex.

4 say they “Strongly disagree”
while 4 say they “Somewhat agree” (which is what I mean by "equal numbers")
Then the result is the lowest “Don’t know / Can’t say” [value="0"]

What should I use for this kind of conditions? and how to build it?

Thanks in advance!

Aucun commentaire:

Enregistrer un commentaire