Example: Client-side validation
This example accesses the DOM of a CRM generated web page to capture and validate events.
The client-side JavaScript performs basic validation by checking if the last name field in the PersonSearchBox is empty before the search details are submitted to the server.
Copy
<script>
// Custom Content - personsearchbox add behaviour to the screen when it has finished loading.
crm.ready(function()
{
// Hide the Search button.
crm.hideButton("Search.gif");
// Add onChange event to the pers_lastname field so that the Search button is shown when a value is entered in field.
$("#pers_lastname").change(function ()
{
if (this.value != '') crm.showButton("Search.gif")
});
})
</script>
For more information about the methods used in this example (such as crm.ready, crm.hideButton, and crm.showButton), see the client-side API reference on the Developer Portal.