Quantcast
Channel: Forums - Recent Threads
Viewing all articles
Browse latest Browse all 143529

Field validation using Javascript

$
0
0

Hello,

The CRM environment of my organization send a XML file to the Department of State almost everyday with several of records, the DOS has a few requirements for fields and there are characters that are not allowed. Initially I was using this code to validate these fields

function ValidateSpecialChar()

{

var Regexp=/[^a-zA-Z0-9 ]/;  //this will allow space

var value=Xrm.Page.getAttribute("name").getValue();

if (Regexp.test(value)) {

 alert("Special Character is Not Allowed !!");

 Xrm.Page.getAttribute("name").setValue(null);

 }

else {

   return false;

 }

}

 

However there are fields that do allow some characters:

  1. The contacts first and last name must be alphabets ([A-Z][a-z])
  2. The account names can have 8 special characters such as & , ', ",  #, -, /, <, >
  3. The city name must be alphabets ([A-Z][a-z])
  4. The phone number attribute can have only  0-9, -, (,) characters as a valid characters
  5. The postal code attribute can have only 0-9, - characters as a valid characters

 Would anyone be able to help me achieve this with Javascript? I can compensate you for time and effort.


Viewing all articles
Browse latest Browse all 143529

Trending Articles