hub.eb?material_id=94

Fields - check values


You can use the logical comparison operators to compare values. These include:

  • ==   returns true if the two values are the same
  • !=   returns true if the two values are different
  • <   returns true if the first value is strictly less than the second value
  • <=   returns true if the first value is less than or equal to the second value
  • >   returns true if the first value is strictly greater than the second value
  • >=   returns true if the first value is greater than or equal to the second value

For example, you can display an error message if two password entered are not the same by using the following code:

if(fields.password.value != fields.confirm_password.value){
  controls.error_text.show;
}

If a field does not have a value, it will return null when you access its value. This can be used to check if the user has not entered a value for a mandatory field:

if(fields.password.value == null){
  controls.error_text.show;
}

Related