I'm using a jquery mobile slider and I have a problem when the value that is entered into the text part of the control is outside of the range of the min and max values that I've set. When the control loses focus, it resets it's value to either the min or max value, whichever is closer to the invalid entered value.
The problem I have is that the user is keying in an invalid value, then clicking the form submit button, and thinking that the value that they've entered has been saved. However, because the slider resets the value to either min or max as soon as it loses focus when the submit button is clicked, this is the value that is actually saved, and not the user entered value.
If this situation arises, I'd like to pop up a message for the user so that they know they've entered an invalid value. Does anyone have any suggestions about how to achieve this? Testing the value in the .change event of the slider is no good as it returns the newly reset value.
Any help much appreciated.
Sample code, as requested:
<script type="text/javascript">
$("#Answer").change(function() {
alert($("#Answer").val()); // this value is already the adjusted value, rather than the user entered value
});
</script>
<label for="Answer" class="ui-input-text"><%=question.Prompt%></label>
<br />
<span id="sliderspan">
<input style="min-width: 3em;" type="range" name="Answer" id="Answer" value="<%=this.Value%>" min="<%=question.MinimumValue %>" max="<%=question.MaximumValue %>" step="0.1" />
<span>°<%=question.Units.ToString()%></span>
</span>