Back

Password Custom Field

Description

The following code can be used to add a Password field to a content structure, including a Form.

Take the following steps to add a Password / Confirm Password field:

  • Click on Structures
  • From the Edit Structure Page click on Add New Field
  • Select: Custom Field
  • Use: Password as the field name
  • Enter the code below in the Code section

Once you save your field, add content to your content structure to test your new Custom Field. The value for the password entered will be added to the field $password.

Code

<input type="password" name="myPasswordField1" id="myPasswordField1" value="$!password">
<br/>Confirm Password:
<input type="password" name="myPasswordField2" id="myPasswordField2" value="$!password" onChange="confirmPwdField('password')">

<script language="">
function confirmPwdField(field) {
   var pwd1 = document.getElementById("myPasswordField1").value;
   var pwd2 = document.getElementById("myPasswordField2").value;
   if(pwd1 == pwd2){
   document.getElementById(field).value = pwd1;
   }else{
   alert("Passwords don't match");
   document.getElementById("myPasswordField1").focus();
   }
}
</script>