Assalamualaikum..
Sila tambah coding ini pada baris terakhir di dalam jquery.validate.js
Contoh 1:
1 2 3 4 5 6 7 8 9 | jQuery.validator.addMethod("money",function(value, element) { var check = false; var re = /^\d{0,11}(\.\d{0,2})?$/; if( re.test(value)){ check = true; } else check = false; return this.optional(element) || check; },"Sila masukkan nilai mata wang"); |
Contoh 2:
1 2 3 4 5 6 7 8 | jQuery.validator.addMethod( "money", function(value, element) { var isValidMoney = /^\d{0,4}(\.\d{0,2})?$/.test(value); return this.optional(element) || isValidMoney; }, "Sila masukkan nilai mata wang" ); |
Dan tambah coding ini pada page validation
1 2 3 4 5 6 7 | $("#myForm").validate({ rules: { nameOfMyInputField: { money: true, } } }); |
Sekian.
*************************************************************
Disediakan Oleh: Haslina Shamsudin
Sumber : Sistem eBajet, http://stackoverflow.com
*************************************************************
0 comments:
Post a Comment