Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

javascript Erroe

Posted on by Microsoft Employee

Hi,

Given below my code.

function example (){
alert('1');
var rgCell = /[0-9]{3}-[0-9]{3}-[0-9]{4}/;
alert('2');
var mobile =Xrm.Page.getAttribute(“new_mobilenum”).getValue( );
alert('3');

}

Hear alert working 1 and 2 but 3 is error. given below  paste my error

Script Error

One of the scripts for this record has caused an error. For more details, download the log file.
ReferenceError: 'example' is undefined at eval code (eval code:1:1)

Regards,

Naresh.

*This post is locked for comments

  • RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: javascript Erroe

    Thanks Naresh.

    Please mark the answer as verified and use new thread for any of your new questions.

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: javascript Erroe

    Hi Ravi,

    Thanks for yor help

    Thanks,

    Naresh.

  • Suggested answer
    RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: javascript Erroe

    Hi Naresh,

    You can try this-

    if (pancard == pancard.toUpperCase()) {

           alert('true');

       }

       else {

           alert('false');

       }

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: javascript Erroe

    Hi,

    function checkPan( )

    {

    var pancard = Xrm.Page.getAttribute("new_pannum").getValue( );

    if(pancard .length != 10 )

    {

    alert('PAN Number not valid. It must be of 10 Digits');

    }

    }

    //Hear alert is working but i need when i enter like this "ctljy6626h" i need  showing to "please enter Capitals" how to write logic please help me.

    Thanks,

    Naresh.

  • Verified answer
    Nithya Gopinath Profile Picture
    Nithya Gopinath 17,074 on at
    RE: javascript Erroe

    Hi Naresh,

    As told by Ravi, you have incorrect braces in the code. Modify the code as shown below.

    function example1() {
        alert('1');
        var Cell = /[0-9]{3}-[0-9]{3}-[0-9]{4}/;
        alert('2');
        var mobile = Xrm.Page.getAttribute("new_mobilenum").getValue();
        if (Cell.Test(mobile)) {
            alert('valid');
        }
        else {
            // Invalid phone number
            alert('Please enter a valid phone number (ex. 123-123-1234).');
        }
    }

    Hope this helps.

  • Verified answer
    RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: javascript Erroe

    You have missing ' }' after the line ' alert('valid');' and have an extra '}' in the end

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: javascript Erroe

    Hi Ravi,

    Given below mention code that showing error. please see the  if any error.

    function example1(){

      alert('1');

      var Cell = /[0-9]{3}-[0-9]{3}-[0-9]{4}/;

      alert('2');

      var mobile =Xrm.Page.getAttribute("new_mobilenum").getValue( );

     if (Cell.Test (mobile ))

    {

      alert('valid');

    else {

    // Invalid phone number

    alert ('Please enter a valid phone number (ex. 123-123-1234).');

    }

    }

    }

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: javascript Erroe

    Hi Alex,

    it is working thanks for your help.

    Thanks,

    Naresh.

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: javascript Erroe

    Hi sandeep,

    Thanks for your help.

    Thanks,

    Naresh.

  • sandeepc Profile Picture
    sandeepc 5,005 on at
    RE: javascript Erroe

    please mark the suggested answers verified if you find it is helpful

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,240 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans