number 9999 comes out as value in the xml?

maybe someone here can help:

I because if there is nothing in the field, the number 9999 comes out in the xml as value

              <input type="hidden" name="Geburtsjahr_Sorgeberechtigter_1" value="9999">            <input type="hidden" name="Geburtsjahr_Sorgeberechtigter_2" value="9999">                    <div class="col-xs-3" style="width: 187px;">Geburtsjahr</div>                        <div class="col-xs-4"   style="width: 272px;">                            <div class="form-group">                                <input type="text" class="form-control" style="width: 125px;" placeholder="JJJJ" name="Geburtsjahr_Sorgeberechtigter_1" id="Geburtsjahr_Sorgeberechtigter_1" value="{if $pdf}{$values.Geburtsjahr_Sorgeberechtigter_1}{/if}" maxlength="4" min="1900" max="2100">                            </div>                        </div>                        <div class="col-xs-3">                            <div class="form-group">                                <input type="text" class="form-control" style="width: 125px;" placeholder="JJJJ" name="Geburtsjahr_Sorgeberechtigter_2" id="Geburtsjahr_Sorgeberechtigter_2" value="{if $pdf}{$values.Geburtsjahr_Sorgeberechtigter_2}{/if}" maxlength="4" min="1900" max="2100">                            </div>                        </div>                        // Geburtsjahr            $(document).ready(function(){                $('#Geburtsjahr_Sorgeberechtigter_1').on('input', function(){                    var eingabeWert = $(this).val();                    if(eingabeWert === ''){                        eingabeWert = '9999';                    }                    $('input[name="Geburtsjahr_Sorgeberechtigter_1"]').attr("value", eingabeWert);                });            });            $(document).ready(function(){                $('#Geburtsjahr_Sorgeberechtigter_2').on('input', function(){                    var eingabeWert = $(this).val();                    if(eingabeWert === ''){                        eingabeWert = '9999';                    }                    $('input[name="Geburtsjahr_Sorgeberechtigter_2"]').attr("value", eingabeWert);                });            });
(1 votes)
Loading...

Similar Posts

Subscribe
Notify of
2 Answers
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
SirGeiler
1 year ago

If I interpret your concerns and circumstances correctly, there are, for example, the following possible solutions:

 value="{if $pdf}{$values.Geburtsjahr_Sorgeberechtigter_1}{else}9999{/if}"

Otherwise following your jQuery approach ( demo ):
Add data-default-years="XXXX" to inputs that should share this behavior.

 <input type="text" class="form-control" data-default-years="9999" value="{if $pdf}...{/if}"> <script type="text/javascript"> // Alle Inputs welche einen Standardwert haben sollen var inputs = $('input[data-default-years]'); // Dein initialer Check $(document).ready(function(){ inputs.trigger('change'); }); // Event bei Änderung des Feldes inputs.on('change', function() { // Aktuellen Wert aus Feld ohne Leerzeichen var value = $(this).val().trim(); // Wenn Wert Zeichenlänge 0 if (!value.length) { // Dann den Data-Wert aus dem Input als Default value = $(this).data('default-years'); } // Wert aktualisieren $(this).val(value); }); </script>
CSANecromancer
1 year ago

Du könntest mit einer XSD einen entsprechenden Defaultwert festlegen:

https://de.wikipedia.org/wiki/XML_Schema