最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

javascript - Unable to validate the "floating numbers" with parsley validator - Stack Overflow

matteradmin3PV0评论

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?

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?

Share asked Apr 24, 2015 at 9:02 PeakGenPeakGen 23.1k100 gold badges285 silver badges493 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 13

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 : )

Post a comment

comment list (0)

  1. No comments so far