Improved trim with multiple form fields.

This commit is contained in:
Martin Edenhofer 2015-09-24 20:33:31 +02:00
parent b8d65a01fe
commit 2dbe64dc15
3 changed files with 14 additions and 3 deletions

View file

@ -452,7 +452,7 @@ class App.ControllerForm extends App.Controller
if typeof param[key.name] is 'string' if typeof param[key.name] is 'string'
param[key.name] = [param[key.name], key.value.trim()] param[key.name] = [param[key.name], key.value.trim()]
else else
param[key.name].push key.value param[key.name].push key.value.trim()
else else
param[key.name] = key.value.trim() param[key.name] = key.value.trim()

View file

@ -22,6 +22,12 @@ body {
<input type="text" value=" a " name="input3"> <input type="text" value=" a " name="input3">
<input type="text" value=" a b " name="input4"> <input type="text" value=" a b " name="input4">
<input type="text" value=" äö ü" name="input5"> <input type="text" value=" äö ü" name="input5">
<input type="text" value=" a " name="input6">
<input type="text" value=" b " name="input6">
<input type="text" value=" c " name="input6">
<input type="text" value=" d " name="input6">
<textarea name="textarea1"></textarea> <textarea name="textarea1"></textarea>
<textarea name="textarea2"> </textarea> <textarea name="textarea2"> </textarea>
<textarea name="textarea3"> a </textarea> <textarea name="textarea3"> a </textarea>

View file

@ -8,6 +8,12 @@ test( 'form trim checks', function() {
input3: 'a', input3: 'a',
input4: 'a b', input4: 'a b',
input5: 'äö ü', input5: 'äö ü',
input6: [
'a',
'b',
'c',
'd'
],
textarea1: '', textarea1: '',
textarea2: '', textarea2: '',
textarea3: 'a', textarea3: 'a',
@ -23,6 +29,5 @@ test( 'form trim checks', function() {
var params = App.ControllerForm.params( el ) var params = App.ControllerForm.params( el )
deepEqual( params, test_params, 'form param check' ) deepEqual( params, test_params, 'form param check' )
console.log('22', params)
console.log('22', test_params)
}) })