@@ -44,28 +44,25 @@ var Waves = (function(Waves, $, undefined) {
44
44
Waves . UI . sendWavesForm = {
45
45
id : 'send-waves-form' ,
46
46
containerId : 'wB-butSend-WAV' ,
47
+ feeInputSelector : '.custom-combobox-input' ,
48
+ errorClass : 'wInput-error' ,
47
49
validator : undefined ,
48
50
getForm : function ( ) {
49
51
return $ ( '#' + Waves . UI . sendWavesForm . id ) ;
50
52
} ,
51
53
setupValidation : function ( ) {
52
54
$ ( '#' + this . containerId ) . on ( $ . modal . BEFORE_OPEN , function ( event , modal ) {
53
55
Waves . UI . sendWavesForm . validator = Waves . UI . sendWavesForm . getForm ( ) . validate ( {
54
- errorClass : 'wInput-error' ,
56
+ errorClass : Waves . UI . sendWavesForm . errorClass ,
55
57
rules : {
56
58
wavesrecipient : {
57
59
required : true ,
58
60
address : true
59
61
} ,
60
62
wavessendamount : {
61
63
required : true ,
62
- decimal : true ,
64
+ decimal : Currency . WAV . precision ,
63
65
min : Waves . UI . constants . MINIMUM_PAYMENT_AMOUNT
64
- } ,
65
- wavessendfee : {
66
- required : true ,
67
- decimal : true ,
68
- min : Waves . UI . constants . MINIMUM_TRANSACTION_FEE
69
66
}
70
67
} ,
71
68
messages : {
@@ -74,15 +71,9 @@ var Waves = (function(Waves, $, undefined) {
74
71
} ,
75
72
wavessendamount : {
76
73
required : 'Amount to send is required' ,
77
- decimal : 'Amount to send must be a decimal number with dot (.) as a decimal separator' ,
74
+ decimal : 'Amount to send must be a decimal number with dot (.) as a decimal separator with no more than {0} fraction digits ' ,
78
75
min : 'Payment amount is too small. It should be greater or equal to ' +
79
76
Waves . UI . constants . MINIMUM_PAYMENT_AMOUNT . toFixed ( Waves . UI . constants . AMOUNT_DECIMAL_PLACES )
80
- } ,
81
- wavessendfee : {
82
- required : 'Transaction fee is required' ,
83
- decimal : 'Transaction fee must be a decimal number with dot (.) as a decimal separator' ,
84
- min : 'Transactions fee is too small. It should be greater or equal to ' +
85
- Waves . UI . constants . MINIMUM_TRANSACTION_FEE
86
77
}
87
78
}
88
79
} ) ;
@@ -91,11 +82,46 @@ var Waves = (function(Waves, $, undefined) {
91
82
$ ( '#' + this . containerId ) . on ( $ . modal . BEFORE_CLOSE , function ( event , modal ) {
92
83
if ( Waves . UI . sendWavesForm . validator !== undefined )
93
84
Waves . UI . sendWavesForm . validator . resetForm ( ) ;
85
+
86
+ $ ( this . feeInputSelector ) . parent ( ) . removeClass ( this . errorClass ) ;
94
87
} ) ;
95
88
} ,
96
89
97
90
isValid : function ( ) {
98
- return this . getForm ( ) . valid ( ) ;
91
+ if ( ! this . getForm ( ) . valid ( ) )
92
+ return false ;
93
+
94
+ // manually validate tx fee cos jquery.validation conflicts with autocomplete.combobox
95
+ var element = $ ( this . feeInputSelector ) ;
96
+ var value = element . val ( ) ;
97
+
98
+ if ( ! $ . validator . methods . required . call ( this . validator , value , element [ 0 ] , true ) ) {
99
+ $ . growl . error ( { message : 'Transaction fee is required' } ) ;
100
+ element . parent ( ) . addClass ( this . errorClass ) ;
101
+
102
+ return false ;
103
+ }
104
+
105
+ if ( ! $ . validator . methods . min . call ( this . validator , value , element [ 0 ] , Waves . UI . constants . MINIMUM_TRANSACTION_FEE ) ) {
106
+ $ . growl . error ( { message : 'Transaction fee is too small. It should be greater or equal to ' +
107
+ Waves . UI . constants . MINIMUM_TRANSACTION_FEE } ) ;
108
+ element . parent ( ) . addClass ( this . errorClass ) ;
109
+
110
+ return false ;
111
+ }
112
+
113
+ if ( ! $ . validator . methods . decimal . call ( this . validator , value , element [ 0 ] , Currency . WAV . precision ) ) {
114
+ $ . growl . error ( { message : 'Transaction fee must be a decimal number with dot (.) as ' +
115
+ 'a decimal separator with no more than ' + Currency . WAV . precision +
116
+ ' fraction digits' } ) ;
117
+ element . parent ( ) . addClass ( this . errorClass ) ;
118
+
119
+ return false ;
120
+ }
121
+
122
+ element . parent ( ) . removeClass ( this . errorClass ) ;
123
+
124
+ return true ;
99
125
}
100
126
} ;
101
127
0 commit comments