Answer the question
In order to leave comments, you need to log in
How to make input validation so that only numbers and (! One) dot or comma would be?
Help refine the regular expression so that using JS and RegExp (probably) to validate the input field so that only numbers or one dot or one comma are entered.
(if there is a semicolon it can't be vice versa)
Here's my solution so far:
<input id = "#inputIn" />
<button id = "#checkIt" >check</button>
<script type = "text/javascript">
document.getElementById("#checkIt").onclick = function () {
alert(/^\s*[\d]+(?:,[\d]+)?\s*$/.test(document.getElementById("#inputIn").value) );
}
</script>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question