admin管理员组

文章数量:1394217

I am trying to use Google's libphonenumber library in my project. I am trying to validate a phone number input using the javascript version, but it is giving me a "goog is not defined" error. I am very new to javascript andI have already spent a day searching for an answer and couldn't find one. The error is in the phonenumberutil.js on the very first line where it says

goog.provide('i18n.phonenumbers.Error');

This library needs the closure library and I have added it as

<!--    Scripts for google phone number validation utils -->
    <tags:script source="/js/GooglePhoneNumberUtils/phonenumberutil.js"/>
    <script src=".js"></script>
    <script>
      goog.require('goog.dom');
      goog.require('goog.json');
      goog.require('goog.proto2.ObjectSerializer');
      goog.require('goog.string.StringBuffer');
    </script>

I have no idea whats going on so please any help will be useful.

I am trying to use Google's libphonenumber library in my project. I am trying to validate a phone number input using the javascript version, but it is giving me a "goog is not defined" error. I am very new to javascript andI have already spent a day searching for an answer and couldn't find one. The error is in the phonenumberutil.js on the very first line where it says

goog.provide('i18n.phonenumbers.Error');

This library needs the closure library and I have added it as

<!--    Scripts for google phone number validation utils -->
    <tags:script source="/js/GooglePhoneNumberUtils/phonenumberutil.js"/>
    <script src="http://closure-library.googlecode./svn/trunk/closure/goog/base.js"></script>
    <script>
      goog.require('goog.dom');
      goog.require('goog.json');
      goog.require('goog.proto2.ObjectSerializer');
      goog.require('goog.string.StringBuffer');
    </script>

I have no idea whats going on so please any help will be useful.

Share Improve this question edited Jan 23, 2013 at 16:11 Joachim Sauer 309k59 gold badges567 silver badges622 bronze badges asked Mar 2, 2012 at 12:01 KhizarKhizar 2,3085 gold badges32 silver badges53 bronze badges 1
  • If you don't want your users to download all those 220 KiloBytes in their web browsers I can suggest you use a lighter (70 KB) port of this library: github./halt-hammerzeit/libphonenumber-js – catamphetamine Commented Dec 2, 2016 at 8:47
Add a ment  | 

1 Answer 1

Reset to default 5

First include 'base.js', then 'phonenumberutil.js'

本文标签: javascriptlibphonenumber goog is not definedStack Overflow