Divyesh Sigmate
Divyesh Sigmate

Reputation: 97

How to Last Name field validation for Contacts module in Sugarcrm?

I am using the SugarCRM version 6.5.26 and I need to validate last_name so that it only accept alphabet Character in contact module. This need to be done on edit view. Currently it accept all type of value due to no validation on input.

Upvotes: 1

Views: 212

Answers (1)

Abdur Rehman
Abdur Rehman

Reputation: 3293

  1. Add a reference to the javascript file which will be needed for event binding.

Path: custom/modules/Contacts/metadata/editviewdefs.php

Code:

<?php

$viewdefs['Contact']['EditView']['templateMeta']['includes'] =
array (
array (
'file' => 'custom/modules/Contacts/js/editview.js',
),
);

?>

  1. Add the javascript file you want to include into the location you referenced above(custom/modules/Contacts/js/editview.js). Check last_name field ID and use following code

    $('input#last_name').bind('keyup blur',function(){ var node = $(this); node.val(node.val().replace(/[^a-z]/g,'') ); } );

  2. Quick Repair, then browser hard refresh. All Done !

Upvotes: 1

Related Questions