Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to validate the "floating numbers" with parsley validator

I am using Parsley validator validating my JSP form. However I am having an issue when validating numbers. Please have a look at the below code.

<form class="form-horizontal" method="post" action="" data-parsley-validate>
    <input id="textinput" name="salary" type="number" required class="form-control input-md" value=<c:out value="${designationInfo.salary}"/> >
</form>

The number field may contain the floating numbers, not only the integers. Numbers like 5500.65 must be allowed. But the parsley validator is checking for "integers" and not submitting the form if it is containing double numbers.

How can I solve this issue?

like image 390
PeakGen Avatar asked Apr 24 '15 09:04

PeakGen


1 Answers

According to this GitHub issue thread I think you can add a step attribute to your input element like this:

    <form class="form-horizontal" method="post" action="" data-parsley-validate>
        <input id="textinput" name="salary" type="number" step="0.01" required class="form-control input-md" value=<c:out value="${designationInfo.salary}"/> >
    </form>

Hope this helps : )

like image 174
tdbts Avatar answered Nov 06 '22 07:11

tdbts