1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044 |
- export default function (qunit, $, Inputmask) {
- qunit.module("Numeric.Extensions");
- qunit.test("€ Currency precision 2", function (assert) {
- var done = assert.async(),
- $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("numeric", {
- groupSeparator: ",",
- placeholder: "0",
- autoGroup: true,
- digits: 2,
- digitsOptional: false,
- prefix: "€ "
- }).mask(testmask);
- testmask.focus();
- $("#testmask").trigger("click");
- setTimeout(function () {
- $("#testmask").Type("1234");
- assert.equal(testmask.value, "€ 1,234.00", "Result " + testmask.value);
- done();
- }, 0);
- });
- qunit.test("integer type 124 correct to 1234", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("numeric", {
- groupSeparator: ",",
- autoGroup: true
- }).mask(testmask);
- testmask.focus();
- $("#testmask").Type("124");
- $.caret(testmask, 2);
- $("#testmask").Type("3");
- assert.equal(testmask.value, "1,234", "Result " + testmask.value);
- });
- qunit.test("numeric type 00000 - Webunity", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("numeric", {
- groupSeparator: ",",
- autoGroup: true,
- integerDigits: 9
- }).mask(testmask);
- testmask.focus();
- $("#testmask").Type("00000");
- $(testmask).trigger("blur");
- assert.equal(testmask.value, "0", "Result " + testmask.value);
- });
- qunit.test("numeric -placeholder 0 type 00000 - Webunity", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("numeric", {
- groupSeparator: ",",
- autoGroup: true,
- placeholder: "0"
- }).mask(testmask);
- testmask.focus();
- $("#testmask").Type("00000");
- assert.equal($("#testmask")[0].inputmask._valueGet(), "0", "Result " + testmask.value);
- });
- qunit.test("numeric placeholder 0 prefix € type 0.123 - Webunity", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("numeric", {
- groupSeparator: ",",
- autoGroup: true,
- placeholder: "0",
- prefix: "€ "
- }).mask(testmask);
- testmask.focus();
- $("#testmask").Type("0.123");
- assert.equal(testmask.value, "€ 0.123", "Result " + testmask.value);
- });
- qunit.test("numeric placeholder 0 prefix € type 0.123 - backspace - Webunity", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("numeric", {
- groupSeparator: ",",
- autoGroup: true,
- placeholder: "0",
- prefix: "€ "
- }).mask(testmask);
- testmask.focus();
- $("#testmask").Type("0.123");
- $("#testmask").SendKey(Inputmask.keyCode.BACKSPACE);
- assert.equal(testmask.value, "€ 0.12", "Result " + testmask.value);
- });
- qunit.test("numeric placeholder 0 prefix € type 0.123 + add 1 in front - Webunity", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("numeric", {
- groupSeparator: ",",
- autoGroup: true,
- placeholder: "0",
- prefix: "€ "
- }).mask(testmask);
- testmask.focus();
- $("#testmask").Type("0.123");
- $.caret(testmask, 2);
- $("#testmask").Type("1");
- assert.equal(testmask.value, "€ 10.123", "Result " + testmask.value);
- });
- qunit.test("numeric placeholder 0 autoGroup: false prefix € type 0.123 + add 123 in front - Webunity", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("numeric", {
- groupSeparator: ",",
- autoGroup: false,
- placeholder: "0",
- prefix: "€ "
- }).mask(testmask);
- testmask.focus();
- $("#testmask").Type("0.123");
- $.caret(testmask, 2);
- $("#testmask").Type("123");
- assert.equal(testmask.value, "€ 1230.123", "Result " + testmask.value);
- });
- qunit.test("numeric placeholder 0 autoGroup: true prefix € type 0.123 + add 123 in front - Webunity", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("numeric", {
- groupSeparator: ",",
- autoGroup: true,
- placeholder: "0",
- prefix: "€ "
- }).mask(testmask);
- testmask.focus();
- $("#testmask").Type("0.123");
- $.caret(testmask, 2);
- $("#testmask").Type("123");
- assert.equal(testmask.value, "€ 1,230.123", "Result " + testmask.value);
- });
- qunit.test("integer alias with integerDigits 9 & autogroup - type 123456789 - gigermocas", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("integer", {
- groupSeparator: ",",
- autoGroup: true,
- integerDigits: 9
- }).mask(testmask);
- testmask.focus();
- $("#testmask").Type("123456789");
- assert.equal(testmask.value, "123,456,789", "Result " + testmask.value);
- });
- qunit.test("integer alias with integerDigits 9 & autogroup - type 1234567890123456789 - gigermocas", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("integer", {
- groupSeparator: ",",
- autoGroup: true,
- integerDigits: 9
- }).mask(testmask);
- testmask.focus();
- $("#testmask").Type("1234567890123456789");
- assert.equal(testmask.value, "123,456,789", "Result " + testmask.value);
- });
- qunit.test("integer alias with integerDigits 4 & autogroup - type 1234567890123456789 - gigermocas", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("integer", {
- groupSeparator: ",",
- autoGroup: true,
- integerDigits: 4
- }).mask(testmask);
- testmask.focus();
- $("#testmask").Type("1234567890123456789");
- assert.equal(testmask.value, "1,234", "Result " + testmask.value);
- });
- qunit.test("decimal alias with integerDigits 9 & autogroup - type 123456789 - gigermocas", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("decimal", {
- groupSeparator: ",",
- autoGroup: true,
- integerDigits: 9
- }).mask(testmask);
- testmask.focus();
- $("#testmask").Type("123456789");
- assert.equal(testmask.value, "123,456,789", "Result " + testmask.value);
- });
- qunit.test("decimal alias with integerDigits 4 & autogroup - type 1234 - gigermocas", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("decimal", {
- groupSeparator: ",",
- autoGroup: true,
- integerDigits: 4
- }).mask(testmask);
- testmask.focus();
- $("#testmask").Type("1234");
- assert.equal(testmask.value, "1,234", "Result " + testmask.value);
- });
- qunit.test("numeric alias with allowMinus:false type=text - vijjj", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("numeric", {
- radixPoint: ".",
- integerDigits: 6,
- allowMinus: false
- }).mask(testmask);
- testmask.focus();
- $("#testmask").Type("123456");
- $.caret(testmask, 0);
- $("#testmask").SendKey("-");
- assert.equal(testmask.value, "123456", "Result " + testmask.value);
- });
- qunit.test("numeric alias with allowMinus:false type=number - mask not applied - MartinVerges", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="number" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("numeric", {
- radixPoint: ".",
- integerDigits: 6,
- allowMinus: false
- }).mask(testmask);
- testmask.focus();
- $("#testmask").Type("123456");
- $("#testmask").SendKey("-");
- //IE7 does not know type=number and treats as type=text
- //noinspection JSUnresolvedFunction
- assert.ok(testmask.value === "" || testmask.value === "123456", "Result " + testmask.value);
- });
- qunit.test("inputmask(\"numeric\", { prefix: \"€ \" }\") - input 12345.12", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("numeric", {
- prefix: "€ "
- }).mask(testmask);
- testmask.focus();
- $("#testmask").Type("12345.12");
- assert.equal(testmask.value, "€ 12345.12", "Result " + testmask.value);
- });
- qunit.test("inputmask(\"decimal\", { autoGroup: true, groupSeparator: \",\" }\") - input 12345.123", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("decimal", {
- autoGroup: true,
- groupSeparator: ","
- }).mask(testmask);
- testmask.focus();
- $("#testmask").SendKey("1");
- $("#testmask").SendKey("2");
- $("#testmask").SendKey("3");
- $("#testmask").SendKey("4");
- $("#testmask").SendKey("5");
- $("#testmask").SendKey(".");
- $("#testmask").SendKey("1");
- $("#testmask").SendKey("2");
- $("#testmask").SendKey("3");
- assert.equal(testmask.value, "12,345.123", "Result " + testmask.value);
- });
- qunit.test("inputmask(\"decimal\", { autoGroup: true, groupSeparator: \",\", decimalProtect: true }\") - input 12345.123 + remove .123", function (assert) {
- var done = assert.async(),
- $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("decimal", {
- autoGroup: true,
- groupSeparator: ",",
- decimalProtect: true
- }).mask(testmask);
- testmask.focus();
- $("#testmask").Type("12345.123");
- $("#testmask").SendKey(Inputmask.keyCode.BACKSPACE);
- $("#testmask").SendKey(Inputmask.keyCode.BACKSPACE);
- $("#testmask").SendKey(Inputmask.keyCode.BACKSPACE);
- $(testmask).trigger("blur");
- setTimeout(function () {
- assert.equal(testmask.value, "12,345", "Result " + testmask.value);
- done();
- }, 0);
- });
- qunit.test("inputmask(\"decimal\", { autoGroup: true, groupSeparator: \",\" }\") - input 12345.123 + replace .123 => .789", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("decimal", {
- autoGroup: true,
- groupSeparator: ","
- }).mask(testmask);
- testmask.focus();
- $("#testmask").Type("12345.123");
- $("#testmask").SendKey(Inputmask.keyCode.LEFT);
- $("#testmask").SendKey(Inputmask.keyCode.LEFT);
- $("#testmask").SendKey(Inputmask.keyCode.LEFT);
- $("#testmask").SendKey(Inputmask.keyCode.DELETE);
- $("#testmask").SendKey(Inputmask.keyCode.DELETE);
- $("#testmask").SendKey(Inputmask.keyCode.DELETE);
- $("#testmask").Type(".789");
- assert.equal(testmask.value, "12,345.789", "Result " + testmask.value);
- });
- qunit.test("inputmask(\"decimal\", { autoGroup: true, groupSeparator: \",\" }\") - input 12345.123 + select replace .123 => .789", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("decimal", {
- autoGroup: true,
- groupSeparator: ","
- }).mask(testmask);
- testmask.focus();
- $("#testmask").Type("12345.123");
- //$("#testmask").trigger("click");
- $.caret(testmask, 6, 10);
- $("#testmask").Type(".789");
- assert.equal(testmask.value, "12,345.789", "Result " + testmask.value);
- });
- qunit.test("inputmask(\"decimal\", { autoGroup: false, groupSeparator: \",\", decimalProtect: true }\") - input 12345.123 + remove .123", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("decimal", {
- autoGroup: false,
- groupSeparator: ",",
- decimalProtect: true
- }).mask(testmask);
- testmask.focus();
- $("#testmask").Type("12345.123");
- //$("#testmask").trigger("click");
- $("#testmask").SendKey(Inputmask.keyCode.LEFT);
- $("#testmask").SendKey(Inputmask.keyCode.LEFT);
- $("#testmask").SendKey(Inputmask.keyCode.LEFT);
- $("#testmask").SendKey(Inputmask.keyCode.LEFT);
- $("#testmask").SendKey(Inputmask.keyCode.DELETE);
- $("#testmask").SendKey(Inputmask.keyCode.DELETE);
- $("#testmask").SendKey(Inputmask.keyCode.DELETE);
- $("#testmask").SendKey(Inputmask.keyCode.DELETE);
- assert.equal(testmask.value, "12345", "Result " + testmask.value);
- });
- qunit.test("inputmask(\"decimal\", { autoGroup: false, groupSeparator: \",\", decimalProtect: false }\") - input 12345.123 + remove .123", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("decimal", {
- autoGroup: false,
- groupSeparator: ",",
- decimalProtect: false
- }).mask(testmask);
- testmask.focus();
- $("#testmask").Type("12345.123");
- //$("#testmask").trigger("click");
- $("#testmask").SendKey(Inputmask.keyCode.LEFT);
- $("#testmask").SendKey(Inputmask.keyCode.LEFT);
- $("#testmask").SendKey(Inputmask.keyCode.LEFT);
- $("#testmask").SendKey(Inputmask.keyCode.LEFT);
- $("#testmask").SendKey(Inputmask.keyCode.DELETE);
- $("#testmask").SendKey(Inputmask.keyCode.DELETE);
- $("#testmask").SendKey(Inputmask.keyCode.DELETE);
- $("#testmask").SendKey(Inputmask.keyCode.DELETE);
- assert.equal(testmask.value, "12345", "Result " + testmask.value);
- });
- qunit.test("inputmask(\"decimal\", { autoGroup: false, groupSeparator: \",\", decimalProtect: true }\") - input 12345.123 + replace .123 => .789", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("decimal", {
- autoGroup: false,
- groupSeparator: ",",
- decimalProtect: true
- }).mask(testmask);
- testmask.focus();
- $("#testmask").Type("12345.123");
- $("#testmask").SendKey(Inputmask.keyCode.LEFT);
- $("#testmask").SendKey(Inputmask.keyCode.LEFT);
- $("#testmask").SendKey(Inputmask.keyCode.LEFT);
- $("#testmask").SendKey(Inputmask.keyCode.LEFT);
- $("#testmask").SendKey(Inputmask.keyCode.DELETE);
- $("#testmask").SendKey(Inputmask.keyCode.DELETE);
- $("#testmask").SendKey(Inputmask.keyCode.DELETE);
- $("#testmask").SendKey(Inputmask.keyCode.DELETE);
- $("#testmask").Type(".789");
- assert.equal(testmask.value, "12345.789", "Result " + testmask.value);
- });
- qunit.test("inputmask(\"decimal\") - maxlength 10", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" maxlength="10" />');
- var testmask = document.getElementById("testmask");
- Inputmask("decimal").mask(testmask);
- testmask.focus();
- $("#testmask").Type("123456789012345");
- assert.equal(testmask.value, "1234567890", "Result " + testmask.value);
- });
- qunit.test("inputmask(\"decimal, { repeat: 15 }\") - maxlength 10", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" maxlength="10" />');
- var testmask = document.getElementById("testmask");
- Inputmask("decimal", {
- repeat: 15
- }).mask(testmask);
- testmask.focus();
- $("#testmask").Type("123456789012345");
- assert.equal(testmask.value, "1234567890", "Result " + testmask.value);
- });
- qunit.test("inputmask(\"decimal, { repeat: 5, decimalProtect: true }\") - maxlength 10", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" maxlength="10" />');
- var testmask = document.getElementById("testmask");
- Inputmask("decimal", {
- repeat: 5,
- decimalProtect: true
- }).mask(testmask);
- testmask.focus();
- $("#testmask").Type("123456789012345");
- assert.equal(testmask.value, "12345", "Result " + testmask.value);
- });
- qunit.test("inputmask(\"decimal, { repeat: 5, decimalProtect: false }\") - maxlength 10", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" maxlength="10" />');
- var testmask = document.getElementById("testmask");
- Inputmask("decimal", {
- repeat: 5,
- decimalProtect: false
- }).mask(testmask);
- testmask.focus();
- $("#testmask").Type("123456789012345");
- assert.equal(testmask.value, "12345.6789", "Result " + testmask.value);
- });
- qunit.test("inputmask(\"decimal\")", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("decimal").mask(testmask);
- testmask.focus();
- $("#testmask").Type("1234567890");
- $.caret(testmask, 0, 10);
- $("#testmask").Type("12345");
- assert.equal(testmask.value, "12345", "Result " + testmask.value);
- });
- qunit.test("inputmask(\"decimal\") - value=\"1234567890\"", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" value="1234567890" />');
- var testmask = document.getElementById("testmask");
- Inputmask("decimal").mask(testmask);
- testmask.focus();
- $.caret(testmask, 0, 10);
- $("#testmask").Type("12345");
- assert.equal(testmask.value, "12345", "Result " + testmask.value);
- });
- qunit.test("inputmask(\"decimal\")", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("decimal").mask(testmask);
- testmask.focus();
- $("#testmask").Type("1234567890");
- $.caret(testmask, 3, 5);
- $("#testmask").SendKey("0");
- assert.equal(testmask.value, "123067890", "Result " + testmask.value);
- });
- qunit.test("inputmask(\"decimal\") - value=\"1234567890\"", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" value="1234567890" />');
- var testmask = document.getElementById("testmask");
- Inputmask("decimal").mask(testmask);
- testmask.focus();
- $.caret(testmask, 3, 5);
- $("#testmask").SendKey("0");
- assert.equal(testmask.value, "123067890", "Result " + testmask.value);
- });
- qunit.test("inputmask(\"decimal\") - value=\"123.45\" Replace last integer", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("decimal", {
- digits: 2
- }).mask(testmask);
- testmask.focus();
- $("#testmask").Type("123.45");
- $.caret(testmask, 2, 3);
- $("#testmask").SendKey("7");
- assert.equal(testmask.value, "127.45", "Result " + testmask.value);
- });
- qunit.test("inputmask(\"decimal\", { digits: 2 }) - value=\"123\" - RomeroMsk", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("decimal", {
- digits: 2
- }).mask(testmask);
- testmask.focus();
- $("#testmask").Type("123");
- $.caret(testmask, 0, 3);
- $("#testmask").Type(",,..");
- $("#testmask").Type("45");
- assert.equal(testmask.value, "0.45", "Result " + testmask.value);
- });
- qunit.test("inputmask - Multiple inputs masked, Integer mask doesn't allow typing - #402 - albatrocity", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- $fixture.append('<input type="text" id="testmask2" />');
- var testmask2 = document.getElementById("testmask2");
- Inputmask("integer", {
- autoGroup: true,
- groupSeparator: ",",
- groupSize: 3
- }).mask(testmask);
- Inputmask("(999)-999-9999").mask(testmask2);
- testmask.focus();
- $("#testmask").Type("12345");
- assert.equal(testmask.value, "12,345", "Result " + testmask.value);
- $("#testmask2").remove();
- });
- qunit.test("decimal alias with groupseparator delete - YoussefTaghlabi", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("decimal", {
- radixPoint: ".",
- groupSeparator: ",",
- groupSize: 3,
- digits: 2,
- autoGroup: true,
- allowPlus: false,
- allowMinus: true
- }).mask(testmask);
- testmask.focus();
- $("#testmask").Type("1234567");
- $.caret(testmask, 0);
- $("#testmask").SendKey(Inputmask.keyCode.DELETE);
- assert.equal(testmask.value, "234,567", "Result " + testmask.value);
- });
- qunit.test("decimal alias with groupseparator backspace - YoussefTaghlabi", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("decimal", {
- radixPoint: ".",
- groupSeparator: ",",
- groupSize: 3,
- digits: 2,
- autoGroup: true,
- allowPlus: false,
- allowMinus: true
- }).mask(testmask);
- testmask.focus();
- $("#testmask").Type("1234567");
- $.caret(testmask, 1);
- $("#testmask").SendKey(Inputmask.keyCode.BACKSPACE);
- assert.equal(testmask.value, "234,567", "Result " + testmask.value);
- });
- qunit.test("decimal alias with plus or minus & autogroup - type -123456 - YoussefTaghlabi", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("decimal", {
- radixPoint: ".",
- groupSeparator: ",",
- groupSize: 3,
- digits: 2,
- autoGroup: true,
- allowPlus: true,
- allowMinus: true
- }).mask(testmask);
- testmask.focus();
- $("#testmask").Type("-123456");
- assert.equal(testmask.value, "-123,456", "Result " + testmask.value);
- });
- qunit.test("decimal alias with plus or minus & autogroup - type 123465 - - YoussefTaghlabi", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("decimal", {
- radixPoint: ".",
- groupSeparator: ",",
- groupSize: 3,
- digits: 2,
- autoGroup: true,
- allowPlus: true,
- allowMinus: true
- }).mask(testmask);
- testmask.focus();
- $("#testmask").Type("123456");
- $.caret(testmask, 0);
- $("#testmask").SendKey("-");
- assert.equal(testmask.value, "-123,456", "Result " + testmask.value);
- });
- qunit.test("decimal alias with plus or minus & autogroup", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("decimal", {
- radixPoint: ".",
- groupSeparator: ",",
- groupSize: 3,
- digits: 2,
- autoGroup: true,
- allowPlus: true,
- allowMinus: true
- }).mask(testmask);
- testmask.focus();
- $("#testmask").Type("1234.56");
- assert.equal(testmask.value, "1,234.56", "Result " + testmask.value);
- });
- qunit.test("decimal alias set value with val() - kochelmonster", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("decimal", {
- radixPoint: ",",
- groupSeparator: ".",
- digits: 2,
- autoGroup: true,
- suffix: ' €'
- }).mask(testmask);
- $("#testmask").val("39.399.392,22 €");
- assert.equal(testmask.value, "39.399.392,22 €", "Result " + testmask.value);
- });
- qunit.test("inputmask(\"decimal\") - value=\"123.1\" blur digitsoptional", function (assert) {
- var done = assert.async(),
- $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("decimal", {
- digits: 3
- }).mask(testmask);
- testmask.focus();
- $("#testmask").Type("123.1");
- $(testmask).trigger("blur");
- setTimeout(function () {
- assert.equal(testmask.value, "123.1", "Result " + testmask.value);
- done();
- }, 0);
- });
- qunit.test("inputmask(\"decimal\") - value=\"123.1\" blur", function (assert) {
- var done = assert.async(),
- $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("decimal", {
- digits: 3,
- digitsOptional: false
- }).mask(testmask);
- testmask.focus();
- $("#testmask").Type("123.1");
- $(testmask).trigger("blur");
- setTimeout(function () {
- assert.equal(testmask.value, "123.100", "Result " + testmask.value);
- done();
- }, 0);
- });
- qunit.test("currency alias - 200000 => replace 2 to 3", function (assert) {
- var done = assert.async(),
- $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("currency").mask(testmask);
- testmask.focus();
- $("#testmask").trigger("click");
- setTimeout(function () {
- $("#testmask").Type("200000");
- $.caret(testmask, 2, 3);
- $("#testmask").Type("3");
- assert.equal(testmask.value, "$ 300,000.00", "Result " + testmask.value);
- done();
- }, 5);
- });
- qunit.test("inputmask(\"integer\") - -0 - laxmikantG", function (assert) {
- var done = assert.async(),
- $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("integer", {
- placeholder: "0"
- }).mask(testmask);
- testmask.focus();
- $("#testmask").Type("-0");
- $(testmask).trigger("blur");
- setTimeout(function () {
- assert.equal(testmask.value, "0", "Result " + testmask.value);
- done();
- }, 0);
- });
- qunit.test("inputmask(\"integer\") - 123- - laxmikantG", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("integer", {
- placeholder: "0"
- }).mask(testmask);
- testmask.focus();
- $("#testmask").Type("123-");
- assert.equal(testmask.value, "-123", "Result " + testmask.value);
- });
- qunit.test("inputmask(\"decimal\") - val(\"-5000,77\"); - ManRueda", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask('decimal', {
- integerDigits: 10,
- groupSeparator: '.',
- autoGroup: true,
- digits: 2,
- radixPoint: ',',
- groupSize: 3
- }).mask(testmask);
- $("#testmask").val("-5000,77");
- assert.equal(testmask.value, "-5.000,77", "Result " + testmask.value);
- });
- qunit.test("inputmask(\"decimal\") - -0 - ManRueda", function (assert) {
- var done = assert.async(),
- $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask('decimal', {
- integerDigits: 10,
- groupSeparator: '.',
- autoGroup: true,
- digits: 2,
- radixPoint: ',',
- groupSize: 3
- }).mask(testmask);
- $("#testmask").val("-0");
- $(testmask).trigger("blur");
- setTimeout(function () {
- assert.equal(testmask.value, "0", "Result " + testmask.value);
- done();
- }, 0);
- });
- qunit.test("inputmask(\"integer\") - -5.000,77 - DrSammyD", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask('integer', {
- placeholder: "0"
- }).mask(testmask);
- $("#testmask").val("-5.000,77");
- $(testmask).trigger("blur");
- assert.equal(testmask.value, "-5000", "Result " + testmask.value);
- });
- qunit.test("inputmask(\"decimal\ placeholder :\"\" digitsoptional: false) - 123 - loostro", function (assert) {
- var done = assert.async(),
- $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" value="0,00" />');
- var testmask = document.getElementById("testmask");
- Inputmask("decimal", {
- radixPoint: ",",
- digits: 2,
- digitsOptional: false,
- autoGroup: true,
- groupSeparator: " ",
- groupSize: 3,
- allowPlus: false,
- allowMinus: false
- }).mask(testmask);
- testmask.focus();
- $("#testmask").trigger("click");
- $.caret(testmask, 0);
- setTimeout(function () {
- $("#testmask").Type("123");
- assert.equal(testmask.value, "123,00", "Result " + testmask.value);
- done();
- }, 5);
- });
- qunit.test("inputmask(\"decimal\ placeholder :\"0\" digitsoptional: false) - .12 - YodaJM", function (assert) {
- var done = assert.async(),
- $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask('decimal', {
- digits: 2,
- placeholder: "0",
- digitsOptional: false
- }).mask(testmask);
- testmask.focus();
- $.caret(testmask, 0, 4);
- setTimeout(function () {
- $("#testmask").Type(".12");
- assert.equal(testmask.value, "0.12", "Result " + testmask.value);
- done();
- }, 0);
- });
- qunit.test("inputmask(\"decimal\") - '8100000.00' - ManRueda", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask('decimal', {
- integerDigits: 6,
- groupSeparator: '.',
- autoGroup: true,
- digits: 2,
- radixPoint: ',',
- groupSize: 3
- }).mask(testmask);
- $("#testmask").val("8100000.00");
- assert.equal(testmask.value, "810.000,00", "Result " + testmask.value);
- });
- qunit.test("inputmask(\"decimal\") - '12345678.12' - ManRueda", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask('decimal', {
- integerDigits: 6,
- groupSeparator: '.',
- autoGroup: true,
- digits: 2,
- radixPoint: ',',
- groupSize: 3
- }).mask(testmask);
- $("#testmask").val("12345678.12");
- assert.equal(testmask.value, "123.456,12", "Result " + testmask.value);
- });
- qunit.test("inputmask(\"decimal\") - '8100000,00' - ManRueda", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask('decimal', {
- integerDigits: 6,
- groupSeparator: '.',
- autoGroup: true,
- digits: 2,
- radixPoint: ',',
- groupSize: 3
- }).mask(testmask);
- $("#testmask").val("8100000,00");
- assert.equal(testmask.value, "810.000,00", "Result " + testmask.value);
- });
- qunit.test("inputmask(\"decimal\") - 8100000.00 - ManRueda", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask('decimal', {
- integerDigits: 6,
- groupSeparator: '.',
- autoGroup: true,
- digits: 2,
- radixPoint: ',',
- groupSize: 3
- }).mask(testmask);
- $("#testmask").val(8100000.00);
- assert.equal(testmask.value, "810.000", "Result " + testmask.value);
- });
- qunit.test("inputmask(\"decimal\") - 8100000.00 digitsoptional false - ManRueda", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask('decimal', {
- integerDigits: 6,
- groupSeparator: '.',
- autoGroup: true,
- digits: 2,
- digitsOptional: false,
- radixPoint: ',',
- groupSize: 3
- }).mask(testmask);
- $("#testmask").val(8100000.00);
- $(testmask).trigger("blur");
- assert.equal(testmask.value, "810.000,00", "Result " + testmask.value);
- });
- qunit.test("inputmask(\"decimal\") - 810000.00 - ManRueda", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("decimal", {
- integerDigits: 6,
- groupSeparator: ".",
- autoGroup: true,
- digits: 2,
- radixPoint: ",",
- groupSize: 3
- }).mask(testmask);
- $("#testmask").val("810000.00");
- assert.equal(testmask.value, "810.000,00", "Result " + testmask.value);
- });
- qunit.test("inputmask(\"decimal\") - 123456 78 - babupca", function (assert) {
- var done = assert.async(),
- $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask({
- alias: "decimal",
- integerDigits: 6,
- digits: 3,
- allowMinus: false,
- digitsOptional: false,
- placeholder: "0"
- }).mask(testmask);
- testmask.focus();
- $("#testmask").trigger("click");
- setTimeout(function () {
- $("#testmask").Type("123456");
- $.caret(testmask, 8);
- $("#testmask").Type("78");
- $.caret(testmask, 5);
- $("#testmask").SendKey(Inputmask.keyCode.BACKSPACE);
- assert.equal(testmask.value, "12346.078", "Result " + testmask.value);
- done();
- }, 0);
- });
- qunit.test("currency alias - 1234 => del 1", function (assert) {
- var done = assert.async(),
- $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("currency").mask(testmask);
- testmask.focus();
- $("#testmask").trigger("click");
- setTimeout(function () {
- $("#testmask").Type("1234");
- $.caret(testmask, 3);
- $("#testmask").SendKey(Inputmask.keyCode.BACKSPACE);
- assert.equal(testmask.value, "$ 234.00", "Result " + testmask.value);
- done();
- }, 5);
- });
- qunit.test("currency alias - 0.02 => type 1 in integer part", function (assert) {
- var done = assert.async(),
- $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("currency").mask(testmask);
- testmask.focus();
- $("#testmask").trigger("click");
- setTimeout(function () {
- $("#testmask").Type("0.02");
- $.caret(testmask, 3);
- $("#testmask").SendKey("1");
- assert.equal(testmask.value, "$ 1.02", "Result " + testmask.value);
- done();
- }, 5);
- });
- qunit.test("currency alias - 0.02 => position before 0 type 1 in integer part", function (assert) {
- var done = assert.async(),
- $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("currency").mask(testmask);
- testmask.focus();
- $("#testmask").trigger("click");
- setTimeout(function () {
- $("#testmask").Type("0.02");
- $.caret(testmask, 2);
- $("#testmask").SendKey("1");
- assert.equal(testmask.value, "$ 10.02", "Result " + testmask.value);
- done();
- }, 5);
- });
- qunit.test("currency alias - 1.23 => del 1 in integer part", function (assert) {
- var done = assert.async(),
- $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("currency").mask(testmask);
- testmask.focus();
- $("#testmask").trigger("click");
- setTimeout(function () {
- $("#testmask").Type("1.23");
- $.caret(testmask, 3);
- $("#testmask").SendKey(Inputmask.keyCode.BACKSPACE);
- assert.equal(testmask.value, "$ 0.23", "Result " + testmask.value);
- done();
- }, 5);
- });
- qunit.test("currency alias - 1234.56 => delete all", function (assert) {
- var done = assert.async(),
- $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("currency").mask(testmask);
- testmask.focus();
- $("#testmask").trigger("click");
- setTimeout(function () {
- $("#testmask").Type("1234.56");
- $.caret(testmask, 0, 10);
- $("#testmask").SendKey(Inputmask.keyCode.BACKSPACE);
- assert.equal($("#testmask")[0].inputmask._valueGet(), "$ 0.00", "Result " + $("#testmask")[0].inputmask._valueGet());
- done();
- }, 5);
- });
- qunit.test("numeric prefix='$' - paste 1234.56 - baileyjames9 & TheAndyBob", function (assert) {
- var done = assert.async(),
- $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("numeric", {
- radixPoint: ".",
- groupSeparator: ",",
- digits: 2,
- autoGroup: true,
- prefix: '$' //No Space, this will truncate the first character
- }).mask(testmask);
- testmask.focus();
- $("#testmask").trigger("click");
- setTimeout(function () {
- $("#testmask").paste("1234.56");
- assert.equal(testmask.value, "$1,234.56", "Result " + testmask.value);
- done();
- }, 5);
- });
- qunit.test("currency alias - 1234.56 => select integer press 1 - babupca", function (assert) {
- var done = assert.async(),
- $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("currency").mask(testmask);
- testmask.focus();
- $("#testmask").trigger("click");
- setTimeout(function () {
- $("#testmask").Type("1234.56");
- $.caret(testmask, 0, 7);
- $("#testmask").SendKey("1");
- assert.equal($("#testmask")[0].inputmask._valueGet(), "$ 1.56", "Result " + $("#testmask")[0].inputmask._valueGet());
- done();
- }, 5);
- });
- qunit.test("currency alias - 123.56 => select integer press 1 - babupca", function (assert) {
- var done = assert.async(),
- $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("currency").mask(testmask);
- testmask.focus();
- $("#testmask").trigger("click");
- setTimeout(function () {
- $("#testmask").Type("123.56");
- $.caret(testmask, 0, 5);
- $("#testmask").SendKey("1");
- assert.equal($("#testmask")[0].inputmask._valueGet(), "$ 1.56", "Result " + $("#testmask")[0].inputmask._valueGet());
- done();
- }, 5);
- });
- qunit.test("currency alias - 123.56 => select integer press 1 - babupca", function (assert) {
- var done = assert.async(),
- $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("currency", {
- prefix: "$"
- }).mask(testmask);
- testmask.focus();
- $("#testmask").trigger("click");
- setTimeout(function () {
- $("#testmask").Type("123.56");
- $.caret(testmask, 0, 4);
- $("#testmask").SendKey("1");
- assert.equal($("#testmask")[0].inputmask._valueGet(), "$1.56", "Result " + $("#testmask")[0].inputmask._valueGet());
- done();
- }, 5);
- });
- qunit.test("currency alias - min 1000", function (assert) {
- var done = assert.async(),
- $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("currency", {
- min: 1000
- }).mask(testmask);
- testmask.focus();
- $(testmask).trigger("blur");
- setTimeout(function () {
- assert.equal($("#testmask")[0].inputmask._valueGet(), "$ 1,000.00", "Result " + $("#testmask")[0].inputmask._valueGet());
- done();
- }, 5);
- });
- qunit.test("currency alias - max 1000 - type 1234", function (assert) {
- var done = assert.async(),
- $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("currency", {
- max: 1000
- }).mask(testmask);
- testmask.focus();
- $("#testmask").trigger("click");
- setTimeout(function () {
- $("#testmask").Type("1234");
- $("#testmask").trigger("blur");
- setTimeout(function () {
- assert.equal($("#testmask")[0].inputmask._valueGet(), "$ 1,000.00", "Result " + $("#testmask")[0].inputmask._valueGet());
- done();
- }, 0);
- }, 5);
- });
- qunit.test("currency alias - type 1010 delete first 1 - FilipeZhou", function (assert) {
- var done = assert.async(),
- $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("currency").mask(testmask);
- testmask.focus();
- $("#testmask").trigger("click");
- setTimeout(function () {
- $("#testmask").Type("1010");
- $.caret(testmask, 3);
- $("#testmask").SendKey(Inputmask.keyCode.BACKSPACE);
- assert.equal($("#testmask")[0].inputmask._valueGet(), "$ 10.00", "Result " + $("#testmask")[0].inputmask._valueGet());
- done();
- }, 0);
- });
- qunit.test("currency alias - type 1010 delete middle 1 - FilipeZhou", function (assert) {
- var done = assert.async(),
- $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("currency").mask(testmask);
- testmask.focus();
- $("#testmask").trigger("click");
- setTimeout(function () {
- $("#testmask").Type("1010");
- $.caret(testmask, 6);
- $("#testmask").SendKey(Inputmask.keyCode.BACKSPACE);
- assert.equal($("#testmask")[0].inputmask._valueGet(), "$ 100.00", "Result " + $("#testmask")[0].inputmask._valueGet());
- done();
- }, 0);
- });
- qunit.test("currency alias - type -1234 delete -", function (assert) {
- var done = assert.async(),
- $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("currency").mask(testmask);
- testmask.focus();
- $("#testmask").trigger("click");
- setTimeout(function () {
- $("#testmask").Type("-1234");
- $.caret(testmask, 0);
- $("#testmask").SendKey(Inputmask.keyCode.DELETE);
- assert.equal($("#testmask")[0].inputmask._valueGet(), "$ 1,234.00", "Result " + $("#testmask")[0].inputmask._valueGet());
- done();
- }, 0);
- });
- qunit.test("decimal alias - type 12345.12 add 6 in front - freeze - DatXN", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("decimal", {
- integerDigits: 5,
- digits: 2,
- allowMinus: false,
- allowPlus: false
- }).mask(testmask);
- testmask.focus();
- $("#testmask").trigger("click");
- $("#testmask").Type("12345.12");
- $.caret(testmask, 0);
- $("#testmask").SendKey("6");
- assert.equal($("#testmask")[0].inputmask._valueGet(), "12345.12", "Result " + $("#testmask")[0].inputmask._valueGet());
- });
- qunit.test("decimal alias - type 123456789 - add , before 8 - jpontet", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("decimal", {
- allowMinus: true,
- integerDigits: 12,
- digits: 2,
- radixPoint: ",",
- autoGroup: true,
- groupSeparator: " ",
- groupSize: 3,
- rightAlign: false
- }).mask(testmask);
- testmask.focus();
- $("#testmask").trigger("click");
- $("#testmask").Type("123456789");
- $.caret(testmask, 9);
- $("#testmask").SendKey(",");
- assert.equal($("#testmask")[0].inputmask._valueGet(), "1 234 567,89", "Result " + $("#testmask")[0].inputmask._valueGet());
- });
- qunit.test("decimal alias - type 123456789 - add , before 8 - backspace - jpontet", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("decimal", {
- allowMinus: true,
- integerDigits: 12,
- digits: 2,
- radixPoint: ",",
- autoGroup: true,
- groupSeparator: " ",
- groupSize: 3,
- rightAlign: false
- }).mask(testmask);
- testmask.focus();
- $("#testmask").trigger("click");
- $("#testmask").Type("123456789");
- $.caret(testmask, 9);
- $("#testmask").SendKey(",");
- $("#testmask").SendKey(Inputmask.keyCode.BACKSPACE);
- assert.equal($("#testmask")[0].inputmask._valueGet(), "1 234 567,89", "Result " + $("#testmask")[0].inputmask._valueGet());
- });
- qunit.test("decimal alias - type 1234567890 - add , before 9 - jpontet", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("decimal", {
- allowMinus: true,
- integerDigits: 12,
- digits: 2,
- radixPoint: ",",
- autoGroup: true,
- groupSeparator: " ",
- groupSize: 3,
- rightAlign: false
- }).mask(testmask);
- testmask.focus();
- $("#testmask").trigger("click");
- $("#testmask").Type("1234567890");
- $.caret(testmask, 11);
- $("#testmask").SendKey(",");
- assert.equal($("#testmask")[0].inputmask._valueGet(), "12 345 678,90", "Result " + $("#testmask")[0].inputmask._valueGet());
- });
- qunit.test("decimal alias - type 1234567890 - add , before 9 - backspace - jpontet", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("decimal", {
- allowMinus: true,
- integerDigits: 12,
- digits: 2,
- radixPoint: ",",
- autoGroup: true,
- groupSeparator: " ",
- groupSize: 3,
- rightAlign: false
- }).mask(testmask);
- testmask.focus();
- $("#testmask").trigger("click");
- $("#testmask").Type("1234567890");
- $.caret(testmask, 11);
- $("#testmask").SendKey(",");
- $("#testmask").SendKey(Inputmask.keyCode.BACKSPACE);
- assert.equal($("#testmask")[0].inputmask._valueGet(), "12 345 678,90", "Result " + $("#testmask")[0].inputmask._valueGet());
- });
- qunit.test("numeric alias - value=\"-1234\" minvalue = 1000", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" value="-1234" />');
- var testmask = document.getElementById("testmask");
- Inputmask("numeric", {
- allowMinus: true,
- min: 1000,
- max: 3000
- }).mask(testmask);
- testmask.blur();
- assert.equal(testmask.inputmask._valueGet(), "1000", "Result " + testmask.inputmask._valueGet());
- });
- qunit.test("numeric alias - value=\"-1234\" minvalue = -1000", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" value="-1234" />');
- var testmask = document.getElementById("testmask");
- Inputmask("numeric", {
- allowMinus: true,
- min: -1000,
- max: 3000
- }).mask(testmask);
- testmask.blur();
- assert.equal(testmask.inputmask._valueGet(), "-1000", "Result " + testmask.inputmask._valueGet());
- });
- qunit.test("numeric alias - value=\"1000\" minvalue = 1000", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" value="1000" />');
- var testmask = document.getElementById("testmask");
- Inputmask("numeric", {
- allowMinus: true,
- min: 1000,
- max: 3000
- }).mask(testmask);
- assert.equal($("#testmask")[0].inputmask._valueGet(), "1000", "Result " + $("#testmask")[0].inputmask._valueGet());
- });
- qunit.test("numeric alias - value=\"-1000\" minvalue = -1000", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" value="-1000" />');
- var testmask = document.getElementById("testmask");
- Inputmask("numeric", {
- allowMinus: true,
- min: -1000,
- max: 3000
- }).mask(testmask);
- assert.equal($("#testmask")[0].inputmask._valueGet(), "-1000", "Result " + $("#testmask")[0].inputmask._valueGet());
- });
- qunit.test("decimal alias - overwrite decimal value - shahvaiz", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("decimal", {
- autoGroup: true,
- groupSeparator: ",",
- suffix: '%'
- }).mask(testmask);
- $("#testmask").Type("123.123");
- $.caret(testmask, 4, 7);
- $("#testmask").Type("4");
- assert.equal($("#testmask")[0].inputmask._valueGet(), "123.4%", "Result " + $("#testmask")[0].inputmask._valueGet());
- });
- qunit.test("numeric alias - placeholder: \"_\" - lucafik", function (assert) {
- var done = assert.async(),
- $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("numeric", {
- integerDigits: 2,
- digits: 2,
- placeholder: "_",
- digitsOptional: false
- }).mask(testmask);
- testmask.focus();
- $("#testmask").trigger("click");
- setTimeout(function () {
- $("#testmask").Type("12");
- assert.equal($("#testmask")[0].inputmask._valueGet(), "12.__", "Result " + $("#testmask")[0].inputmask._valueGet());
- done();
- }, 0);
- });
- qunit.test("numeric alias - type 123.123 - delete all - ivodopyanov", function (assert) {
- var done = assert.async(),
- $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("numeric").mask(testmask);
- $("#testmask").trigger("click");
- setTimeout(function () {
- $("#testmask").Type("123.123");
- $.caret(testmask, 0, testmask.value.length);
- $("#testmask").SendKey(Inputmask.keyCode.DELETE);
- assert.equal($("#testmask")[0].inputmask._valueGet(), "", "Result " + $("#testmask")[0].inputmask._valueGet());
- done();
- }, 0);
- });
- qunit.test("currency alias - 123 - isvalid - ivodopyanov", function (assert) {
- var done = assert.async(),
- $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("currency").mask(testmask);
- $("#testmask").trigger("click");
- setTimeout(function () {
- $("#testmask").Type("123");
- var isValid = Inputmask("currency").isValid(testmask.value);
- assert.equal(isValid, true, "Result " + $(testmask).val() + " : " + isValid);
- done();
- }, 0);
- });
- qunit.test("currency alias - $ 99,999,999.00 - isvalid - ivodopyanov", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("currency").mask(testmask);
- $("#testmask").Type("$ 99,999,999.00");
- var isValid = Inputmask("currency").isValid(testmask.value);
- assert.equal(isValid, true, "Result " + $(testmask).val() + " : " + isValid);
- });
- qunit.test("numeric alias - digits 2 type 0.12 - gharlan", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" value="0.12" />');
- var testmask = document.getElementById("testmask");
- Inputmask("numeric", {
- digits: 2
- }).mask(testmask);
- $.caret(testmask, 0, 1);
- $("#testmask").Type("1");
- assert.equal($("#testmask")[0].inputmask._valueGet(), "1.12", "Result " + $("#testmask")[0].inputmask._valueGet());
- });
- qunit.test("numeric alias - digits 2 select 0 type 1 - gharlan", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" value="0.00" />');
- var testmask = document.getElementById("testmask");
- Inputmask("numeric", {
- digits: 2
- }).mask(testmask);
- $.caret(testmask, 0, 1);
- $("#testmask").Type("1");
- assert.equal($("#testmask")[0].inputmask._valueGet(), "1.00", "Result " + $("#testmask")[0].inputmask._valueGet());
- });
- qunit.test("decimal alias - value 20,00 select 2 type 5 - schmulschubiak", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" value="20,00" />');
- var testmask = document.getElementById("testmask");
- Inputmask("decimal", {
- radixPoint: ",",
- autoGroup: true,
- groupSeparator: " ",
- groupSize: 3,
- allowMinus: false,
- digits: 2,
- rightAlign: false
- }).mask(testmask);
- $.caret(testmask, 0, 1);
- $("#testmask").Type("5");
- assert.equal($("#testmask")[0].inputmask._valueGet(), "50,00", "Result " + $("#testmask")[0].inputmask._valueGet());
- });
- qunit.test("currency numericInput true - type 10020 - jaisonerick", function (assert) {
- var done = assert.async(),
- $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("currency", {
- allowPlus: false,
- allowMinus: false,
- rightAlign: false,
- groupSeparator: '.',
- radixPoint: ',',
- numericInput: true,
- digits: 2,
- prefix: 'R$ ',
- unmaskAsNumber: false
- }).mask(testmask);
- testmask.focus();
- $("#testmask").trigger("click");
- setTimeout(function () {
- $("#testmask").Type("10020");
- assert.equal($(testmask).val(), "R$ 100,20", "Result " + $(testmask).val());
- done();
- }, 0);
- });
- qunit.test("numeric - type 978-3498064365 - andreasba", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("numeric").mask(testmask);
- $("#testmask").Type("978-3498064365");
- assert.equal($(testmask).val(), "-9783498064365", "Result " + $(testmask).val());
- });
- qunit.test("numeric - type 978-3498064365 - andreasba", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("numeric", {
- allowMinus: false
- }).mask(testmask);
- testmask.focus();
- $("#testmask").Type("978-3498064365");
- assert.equal($(testmask).val(), "9783498064365", "Result " + $(testmask).val());
- });
- qunit.test("currency alias - isvalid - ivodopyanov - htmlmasta", function (assert) {
- var done = assert.async(),
- $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("currency").mask(testmask);
- testmask.focus();
- $("#testmask").trigger("click");
- setTimeout(function () {
- var i, isValid;
- for (i = 0; i < 10; i++) {
- $("#testmask").Type("9");
- isValid = Inputmask("currency").isValid(testmask.value);
- assert.equal(isValid, true, "Value: \"" + testmask.value + "\"; isValid: " + isValid);
- }
- done();
- }, 0);
- });
- qunit.test("currency - goto last decimal place type 2", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("currency").mask(testmask);
- testmask.focus();
- $.caret(testmask, 5);
- $("#testmask").Type("2");
- assert.equal($(testmask).val(), "$ 0.02", "Result " + $(testmask).val());
- });
- qunit.test("decimal minvalue 0,3 - enter 0,2 - Aifz", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask({
- 'alias': 'decimal',
- 'radixPoint': ',',
- 'digits': '2',
- 'min': '0,3',
- 'max': '5',
- 'allowMinus': false
- }).mask(testmask);
- testmask.focus();
- $("#testmask").Type("0,2");
- testmask.blur();
- assert.equal($(testmask).val(), "0,3", "Result " + $(testmask).val());
- });
- qunit.test("currency max = 100 - type 200 - zigtechjs", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("percentage", {
- placeholder: "_",
- digitsOptional: false,
- max: 100,
- }).mask(testmask);
- testmask.focus();
- $("#testmask").Type("200");
- testmask.blur();
- assert.equal($(testmask).val(), "100.00 %", "Result " + $(testmask).val());
- });
- qunit.test("Numbers get swapped when cursor near suffix. #1278 - xklepio", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask('decimal', {
- radixPoint: ',',
- groupSeparator: '.',
- autoGroup: true,
- repeat: 10,
- digits: '2',
- autoUnmask: true,
- suffix: ' €'
- }).mask(testmask);
- testmask.focus();
- $.caret(testmask, 1);
- $("#testmask").Type("52");
- assert.equal($("#testmask")[0].inputmask._valueGet(), "52 €", "Result " + $("#testmask")[0].inputmask._valueGet());
- });
- qunit.test("numeric + numericInput #1328 - douglasdtc", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("numeric", {
- 'groupSeparator': '.',
- 'groupSize': 3,
- 'radixPoint': ',',
- 'numericInput': true,
- 'digits': 2
- }).mask(testmask);
- testmask.focus();
- $("#testmask").val("237,38");
- assert.equal(testmask.value, "237,38", "Result " + testmask.value);
- });
- qunit.test("numeric + type -", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("currency", {negationSymbol: {front: "(", back: ")"}}).mask(testmask);
- testmask.focus();
- $.caret(testmask, 1);
- $("#testmask").Type("-");
- assert.equal(testmask.value, "($ 0.00)", "Result " + testmask.value);
- });
- qunit.test("numeric + type 123 - select partial type 0", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("currency").mask(testmask);
- testmask.focus();
- $("#testmask").Type("123");
- $.caret(testmask, 0, 5);
- $("#testmask").Type("0");
- assert.equal(testmask.inputmask._valueGet(), "$ 0.00", "Result " + testmask.inputmask._valueGet());
- });
- qunit.test("numeric + groupSeparator: \" \" backspace, - krajcot", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("currency", {
- digits: 0,
- groupSeparator: " ",
- autoGroup: true
- }).mask(testmask);
- testmask.focus();
- $("#testmask").Type("1");
- $.caret(testmask, 3);
- $("#testmask").SendKey(Inputmask.keyCode.BACKSPACE);
- assert.equal(testmask.inputmask._valueGet(), "$ 0", "Result " + testmask.inputmask._valueGet());
- });
- qunit.test("numeric + groupSeparator: \" \" delete, - krajcot", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("currency", {
- digits: 0,
- groupSeparator: " ",
- autoGroup: true
- }).mask(testmask);
- testmask.focus();
- $("#testmask").Type("1");
- $.caret(testmask, 2);
- $("#testmask").SendKey(Inputmask.keyCode.DELETE);
- assert.equal(testmask.inputmask._valueGet(), "$ 0", "Result " + testmask.inputmask._valueGet());
- });
- qunit.test("minvalue, - serGlazkov", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask({
- alias: 'integer',
- autoUnmask: true,
- rightAlign: false,
- min: 18,
- max: 80,
- prefix: '',
- suffix: ' %',
- }).mask(testmask);
- testmask.focus();
- $("#testmask").Type("30");
- $.caret(testmask, 1);
- $("#testmask").SendKey(Inputmask.keyCode.DELETE);
- $("#testmask").Type("1");
- assert.equal(testmask.inputmask._valueGet(), "31 %", "Result " + testmask.inputmask._valueGet());
- });
- qunit.test("groupseparator ' ' - krajcot", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("currency", {
- groupSeparator: " ",
- autoGroup: true,
- suffix: " €",
- prefix: "",
- digits: 0,
- inputEventOnly: false
- }).mask(testmask);
- testmask.focus();
- testmask.blur();
- assert.equal(testmask.inputmask._valueGet(), "0 €", "Result " + testmask.inputmask._valueGet());
- });
- qunit.test("decimal set 0.50", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("decimal", {
- radixPoint: ',',
- groupSeparator: '.',
- autoGroup: true,
- digits: 2,
- removeMaskOnSubmit: false
- }).mask(testmask);
- $(testmask).val("0.50");
- assert.equal(testmask.inputmask._valueGet(), "0,50", "Result " + testmask.inputmask._valueGet());
- });
- qunit.test("decimal set 1.000", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("decimal", {
- radixPoint: ',',
- groupSeparator: '.',
- autoGroup: true,
- digits: 2,
- removeMaskOnSubmit: false
- }).mask(testmask);
- $(testmask).val("1.000");
- assert.equal(testmask.inputmask._valueGet(), "1.000", "Result " + testmask.inputmask._valueGet());
- });
- qunit.test("decimal set 1234.56", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("decimal", {
- radixPoint: ',',
- groupSeparator: '.',
- autoGroup: true,
- digits: 2,
- removeMaskOnSubmit: false
- }).mask(testmask);
- $(testmask).val("1234.56");
- assert.equal(testmask.inputmask._valueGet(), "1.234,56", "Result " + testmask.inputmask._valueGet());
- });
- qunit.test("currency set 100.00 - NurGuz", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("currency", {radixPoint: ","}).mask(testmask);
- $(testmask).val("100.00");
- assert.equal(testmask.inputmask._valueGet(), "$ 100,00", "Result " + testmask.inputmask._valueGet());
- });
- qunit.test("decimal suffix: years => yers - marcelokohl", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask('decimal', {
- suffix: " years",
- rightAlign: false,
- onBeforeMask: function (value, opts) {
- return value;
- }
- }).mask(testmask);
- $(testmask).val("1");
- assert.equal(testmask.inputmask._valueGet(), "1 years", "Result " + testmask.inputmask._valueGet());
- });
- qunit.test("decimal type 38700 delete 7 type 8 - Borzák Attila", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("decimal",
- {autoGroup: true, groupSeparator: ","}).mask(testmask);
- $(testmask).Type("38800");
- $.caret(testmask, 3);
- $("#testmask").SendKey(Inputmask.keyCode.DELETE);
- $("#testmask").Type("8");
- assert.equal(testmask.inputmask._valueGet(), "38,800", "Result " + testmask.inputmask._valueGet());
- });
- qunit.test("decimal type 100. delete - Borzák Attila", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask("decimal",
- {autoGroup: true, groupSeparator: ","}).mask(testmask);
- $(testmask).Type("100.");
- $("#testmask").SendKey(Inputmask.keyCode.BACKSPACE);
- assert.equal(testmask.inputmask._valueGet(), "100", "Result " + testmask.inputmask._valueGet());
- });
- qunit.test("Currency digits and delete #1351 - kousenlsn", function (assert) {
- var $fixture = $("#qunit-fixture");
- $fixture.append('<input type="text" id="testmask" />');
- var testmask = document.getElementById("testmask");
- Inputmask( {
- max: '99999999.99',
- alias: 'currency',
- prefix: '',
- allowPlus: false,
- autoUnmask: true}).mask(testmask);
- $(testmask).Type("1.23");
- $.caret(testmask, 0);
- $("#testmask").SendKey(Inputmask.keyCode.DELETE);
- $("#testmask").SendKey(Inputmask.keyCode.DELETE);
- $("#testmask").SendKey(Inputmask.keyCode.DELETE);
- assert.equal(testmask.inputmask._valueGet(), "0.00", "Result " + testmask.inputmask._valueGet());
- });
- };
|