How to apply the CSS class “hidden” to the field rows of the fields needed to be suppressed and set the value on the inputs to a default value

烂漫一生 提交于 2019-12-13 22:06:37

问题


I have to hide the fields password and verify password from UI screen and assign a default password xyz for the new users created. Please suggest how I can do that in the below snippet:

<div class="field-row">
  <span class="crud-label">${msg("bel.password")}:&nbsp;*</span>
</div>
<div class="field-row" type="hidden">
  <input class="crud-input" id="${el}-create-password" type="password" maxlength="100" />
</div>
<div class="field-row">
  <span class="crud-label">${msg("label.rifypassword")}:&nbsp;*</span>
</div>
<div class="field-row" type="hidden">
  <input class="crud-input" id="${el}-create-verifypassword" type="password" maxlength="100" />
</div>

回答1:


Seeing that no one helped you yet, let me help you here :).

You can set a default value on an input field with the "value" property.

Use this HTML:

<div class="field-row">
  <span class="crud-label">${msg("bel.password")}:&nbsp;*</span>
</div>
<div class="field-row hidden" type="hidden">
  <input class="crud-input" id="${el}-create-password" value="defaultPassword" type="password" maxlength="100" />
</div>
<div class="field-row">
  <span class="crud-label">${msg("label.rifypassword")}:&nbsp;*</span>
</div>
<div class="field-row hidden" type="hidden">
  <input class="crud-input" id="${el}-create-verifypassword" value="defaultPassword" type="password" maxlength="100" />
</div>

This will result in your default password values to be "defaultPassword".

Now, to hide these fields, you can use CSS:

.hidden {
    display: none;
}

Note that in the HTML I added extra class names. You add extra class names by just adding more to the class="", seperated by a space.

If you use jQuery or something, you can also set the display to none with:

$(".hidden").css("display", "none");

Hope this helped you!




回答2:


If you hide the password & confirm password controls in alfresco share, the form will not be sent to the server. So disable them and set the default values for it.

Hope the below code helps you.

 <div class="field-row">
                  <input class="crud-input" id="${el}-create-password" type="password" maxlength="100" value="admin"  disabled="disabled"/>
               </div>
               <div class="field-row">
                  <span class="crud-label">${msg("label.verifypassword")}:&nbsp;*</span>
               </div>
               <div class="field-row">
                  <input class="crud-input" id="${el}-create-verifypassword" type="password" maxlength="100" value="admin"  disabled="disabled"/>
               </div>


来源:https://stackoverflow.com/questions/40653019/how-to-apply-the-css-class-hidden-to-the-field-rows-of-the-fields-needed-to-be

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!