Skip to content

add Demo #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 78 additions & 0 deletions demo.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script type="text/javascript" src="jquery.numeric.min.js"></script>
</head>
<body>
<form>
<label for="numbers-only">Numbers only:</label>
<input class="numeric" type="text" id="numbers-only" />
<br /><br />
<label for="integers-only">Integers only:</label>
<input class="integer" type="text" id="integers-only" />
<br /><br />
<label for="positive">No negative values:</label>
<input class="positive" type="text" id="positive"/>
<br /><br />
<label for="no-negative">No negative values (integer only):</label>
<input class="positive-integer" type="text" id="no-negative"/>
<br /><br />
<label for="decimal-2-places">Numbers with up to 2 decimal places:</label>
<input class="decimal-2-places" type="text" id="decimal-2-places"/>
<br /><br />
<label for="alternative-decimal-separator">Alternative (,) changes to standard (.) decimal separator:</label>
<input class="alternative-decimal-separator" type="text" id="alternative-decimal-separator"/>
<br /><br />
<label for="alternative-decimal-separator-reverse">Reverse change from alternative (.) to standard (,) decimal separator:</label>
<input class="alternative-decimal-separator-reverse" type="text" id="alternative-decimal-separator-reverse" />
<br /><br />
<a href="#" id="remove">Remove numeric</a>
</form>
<script type="text/javascript">
$('.numeric').numeric();

$('.integer').numeric(
false,
function () {
alert('Integers only');
this.value = '';
this.focus();
}
);

$('.positive').numeric(
{negative: false},
function () {
alert('No negative values');
this.value = '';
this.focus();
}
);

$('.positive-integer').numeric(
{decimal: false, negative: false},
function () {
alert('Positive integers only');
this.value = '';
this.focus();
}
);

$('.decimal-2-places').numeric({decimalPlaces: 2});

$('.alternative-decimal-separator').numeric({altDecimal: ','});

$('.alternative-decimal-separator-reverse').numeric({altDecimal: '.', decimal: ','});

$('#remove').on(
'click',
function (e) {
e.preventDefault();

$('.numeric,.integer,.positive,.positive-integer,.decimal-2-places,.alternative-decimal-separator,.alternative-decimal-separator-reverse').removeNumeric();
}
);
</script>
</body>
</html>