Skip to content

Commit b5dd995

Browse files
committed
More updates
Removed eventsFilter in formValidation. Removed unnecessary code from webpack.config.js. Changed event from `change` to `keyup` for better experience.
1 parent 2b74447 commit b5dd995

3 files changed

Lines changed: 4 additions & 25 deletions

File tree

samples/jquery/00 ShoppingForm/src/modules/app/app.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,16 @@ class App {
5050

5151
setEventHandlers() {
5252
$selBrands.change(this.onBrandSelect);
53-
$txtNif.change(this.onFieldChange);
54-
$txtDiscount.change(this.onFieldChange);
53+
$txtNif.keyup(this.onFieldChange);
54+
$txtDiscount.keyup(this.onFieldChange);
5555
$txtDiscount.on('input', this.onDiscountType);
5656
$formProducts.submit(this.onSubmit);
5757
}
5858

5959
onBrandSelect(event) {
6060
this.onFieldChange(event);
6161
const product = Number(event.currentTarget.value) || null;
62-
const isValidProduct = product !== null;
62+
const isValidProduct = (product !== null);
6363
if (!isValidProduct) {
6464
$selProducts.val('');
6565
}
@@ -125,7 +125,7 @@ class App {
125125
onFieldChange(event) {
126126
const $field = $(event.currentTarget);
127127
productsFormValidation
128-
.validateField(null, $field.attr('name'), $field.val(), { onChange: true })
128+
.validateField(null, $field.attr('name'), $field.val())
129129
.then(validationResult => {
130130
this.toggleErrorMessage(validationResult, $field);
131131
})

samples/jquery/00 ShoppingForm/src/modules/app/validation/formProductValidationService.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,30 +12,25 @@ const validationConstraints = {
1212
product: [
1313
{
1414
validator: Validators.required,
15-
eventsFilter: { onSubmit: true, onChange: true },
1615
},
1716
],
1817
version: [
1918
{
2019
validator: Validators.required,
21-
eventsFilter: { onSubmit: true, onChange: true },
2220
},
2321
],
2422
discountCode: [
2523
{
2624
validator: Validators.pattern,
2725
customParams: { pattern: DISCOUNT_REGEXP },
28-
eventsFilter: { onSubmit: true, onChange: true },
2926
}
3027
],
3128
nif: [
3229
{
3330
validator: Validators.required,
34-
eventsFilter: { onSubmit: true, onChange: true },
3531
},
3632
{
3733
validator: nifValidator,
38-
eventsFilter: { onSubmit: true, onChange: true },
3934
}
4035
]
4136
}

samples/jquery/00 ShoppingForm/webpack.config.js

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,10 @@ var basePath = __dirname;
77

88
module.exports = {
99
context: path.join(basePath, "src"),
10-
resolve: {
11-
// .js is required for react imports.
12-
// .tsx is for our app entry point.
13-
// .ts is optional, in case you will be importing any regular ts files.
14-
extensions: ['.js']
15-
},
1610

1711
entry: {
1812
app: './index.js',
19-
styles: [
20-
'./css/site.css',
21-
],
2213
vendor: [
23-
"bootstrap",
2414
"jquery",
2515
"core-js",
2616
"lc-form-validation",
@@ -74,7 +64,6 @@ module.exports = {
7464
plugins: [
7565
new webpack.optimize.CommonsChunkPlugin({
7666
name: 'vendor',
77-
filaneme: 'vendor.js'
7867
}),
7968
//Generate index.html in /dist => https://github.com/ampedandwired/html-webpack-plugin
8069
new HtmlWebpackPlugin({
@@ -83,10 +72,5 @@ module.exports = {
8372
}),
8473
//Generate bundle.css => https://github.com/webpack/extract-text-webpack-plugin
8574
new ExtractTextPlugin('[name].css'),
86-
//Expose jquery used by bootstrap
87-
new webpack.ProvidePlugin({
88-
$: "jquery",
89-
jQuery: "jquery"
90-
})
9175
]
9276
}

0 commit comments

Comments
 (0)