Validate phone type fields by JavaScript

Hello.
I'm using JavaScript to validate some fields on Contact entity like the date of birth. Erevything is working very well. To do that we use the name of the object on the source code of the web page for example "ContactEditForm.Date of Birth". But when we try to validate the phone type fields using the same method, the JavaScript doesn't work because all of them have symbols on the name ("ContactEditForm.Fax Phone &#35", "ContactEditForm.Assistant Phone &#35", "ContactEditForm.Cellular Phone &#35"). We need to use these fields, so we can't change them. And we must validate them before the user clicks on save buttom, so we are using JavaScript on the Global Web Applets. How can we reference these exactly fields on JavaScript code to validade them on Global Web Applets? Can anybody help me?
Thanks in advance.

Hello Royston,
This is part of the code that I use to reference the fields of phone number.
//Try 1: document.getElementById("ContactEditForm.Fax Phone #;").onkeypress = new Function('limpaTelefone(this);');
//Try 2: document.getElementById("ContactEditForm.Home Phone #").onkeypress = new Function('limpaTelefone(this);');
Thanks for your help.

Similar Messages

  • How to updateControlValue of lookup custom type field via javascript (JSLink) ?

    I found in context - fieldSchema - Choices - array with lookup items, so i created new object with lookupid and lookupvalue and pushed into Choices. But after update control value i found what fieldValue: "1218;#"; while in  context
    - fieldSchema - Choices - array my Object [LookupId: 1218; LookupValue: "Dion"]; 
    Out of array LookupValue always null. Any idea?

    Hi,
    The following links would be helpful:
    Setting values of SharePoint Lookup field
    http://snipplr.com/view/30179/setting-values-of-sharepoint-lookup-field/
    Sharepoint 2013. Multivalue lookup field with JavaScript
    http://stackoverflow.com/questions/22694749/sharepoint-2013-multivalue-lookup-field-with-javascript
    Best Regards,
    Dennis Guo
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]
    Unfortunatly it is not what i need. 
    Let me explain, i trying to make cross site lookup field. So for now i made javaScript file and overrided JSLInk parameter. 
    I want to made it clear for sharepoint and followed clientforms.debug.js practice. 
    in clientforms.debug.js they used updateControlValue method for update fieldValue. So, i use this method for insert my own lookup object to field value. And main problem - updating field value such as the string  "5233;#HelpMePlz". 
    Cuz after method updateControlValue sharepoint not save my own object.LookupValue  (HelpMePlz), sharepoint only save object.LookupId (5233). I
    need someone who has already done something similar and can explain the subtleties of working with a client side rendering (JSLink) & lookup field. If any know how to do it write plz here or mail me ([email protected]). its realy important to me,thx.

  • To find the date type fields in the row and validate those date fields

    TYPES : BEGIN OF TY_MARA,
              MATNR TYPE MARA-MATNR,
              ERSDA TYPE MARA-ERSDA,
              ERNAM TYPE MARA-ERNAM,
              LAEDA TYPE MARA-LAEDA,
              MTART TYPE MARA-MTART,
            END OF TY_MARA.
    DATA : it_mara TYPE STANDARD TABLE OF ty_mara,
          it_mara1 TYPE STANDARD TABLE OF ty_mara,
           wa_mara TYPE ty_mara.
    loop at it_mara into wa_mara.
      describe field wa_mara-ersda type c_data.
    if c_data eq 'D'.
      CALL FUNCTION 'DATE_CHECK_PLAUSIBILITY'
        EXPORTING
          date                            = wa_mara-ersda
       EXCEPTIONS
         PLAUSIBILITY_CHECK_FAILED       = 1
         OTHERS                          = 2
      IF sy-subrc eq 0.
    wa_mara-ersda = '00000000'.
        append wa_mara to it_mara1.
        write :wa_mara-matnr,wa_mara-ersda.
        else.
            wa_mara-ersda = '00000000'.
        append wa_mara to it_mara1.
        write :wa_mara-matnr,wa_mara-ersda.
      ENDIF.
      endif.
      endloop.
    This issue regarding how to find the date type fields in the row and validate those date fields.If its not a valid date ,i have to assign initial value to that.
    I've tried that for single field using describe field.Please help me do that for all fields.

    Hi Sam,
     I believe we had discussed the same issue in the below thread. Can you please refer the below one?
    http://social.msdn.microsoft.com/Forums/sharepoint/en-US/d93e16ff-c123-4b36-b60b-60ccd34f6ca7/calculate-time-differences-in-infopath?forum=sharepointcustomizationprevious
    If it's not helping you please let us know
    Sekar - Our life is short, so help others to grow
    Whenever you see a reply and if you think is helpful, click "Vote As Helpful"! And whenever
    you see a reply being an answer to the question of the thread, click "Mark As Answer

  • How to validate an text field item using javascript for numbers only.

    hi,
    how to validate an text field item using javascript for numbers only.please help me on this urgent
    please mail me solun if posible on [email protected]

    Hi,
    Page HTML header
    <script>
    function onlyNum(evt) {
      // Usage: onKeyPress="return onlyNum(event)"
      evt = (evt) ? evt : window.event;
      var charCode = (evt.which) ? evt.which : evt.keyCode;
      if (charCode > 31 && (charCode < 48 || charCode > 57)) {
        var status = 'This field accepts numbers only!';
        alert(status);
        return false;
      var status = '';
      return true;
    </script>Item HTML Form Element Attributes
    onKeyPress="return onlyNum(event)"Br,Jari

  • Number of lines in a Field of type Text with Javascript

    Hi,
    I have a form where I need to dynamically retrieve the number of lines in a Field of type Text.
    When I use getField(), I'm returned an object of type Field. I can see such properties as rect, but nothing concerning the number of lines of text in the field.
    Any idea (other than getting the Field height and dividing that by the height of a line) ?
    Regards,
    Karl.

    Hi,
    You can use below function to calculate the no of lines in the Text field dynamically.
    import mx.controls.textClasses.TextRange;
        import flash.text.TextField;
        private function calculateNoOfLines():int
          var tr2:TextRange = new TextRange(_text, true, 0,_text.text.length-1);
          tr2.text = _text.text;
          _text.invalidateSize();
          _text.invalidateDisplayList();
          _text.invalidateProperties();
          var contentTextField:TextField = _text.mx_internal::getTextField();                           
                  var nLines:int = contentTextField.numLines;
                  var lineMetrics:TextLineMetrics = _text.getLineMetrics(0);
                  // This is to calculate the total text height
                  var _textHeight:Number = lineMetrics.height * nLines;
         return nLines;    
    Call the above function in the KeyUp event of the Text field.
    Here in the above field _text is the Text field.
    <mx:Text id="_text" />
    If this post answers your question or helps, please kindly mark it as such.
    Thanks,
    Bhasker Chari

  • Phone number field

    I am trying to create a phone number field that will automatically create the dashes as they are typing in the numbers. For example: i type 222 and a dash follows after the last 2 automatically. I know about the regular expression validation you can set, but it is a little complicated for the end user.

    Add the JavaScript to the HTML Header field of the Page definition.
    Then add the following to the HTML Form Element Attributes of your field:
    onclick="javascript:getIt(this)"However, be aware that the Javascript function in the example expects a particular document structure - it is not written generically so you will have to spend some time updating the example OR find another one.

  • How to prevent users from entering '+' or '0' in front of country code in the phone number field?

    Requirement:
    How can I prevent guest users from entering '+' sign or '0' in front of country-code in the visitor phone number field during self registration?
    Few SMS service providers are not looking for '+' sign or '0' or '00' in front of the international phone numbers to trigger the sms. Providing these values in front of country code during self-registration may fail to deliver the sms to recipient.
    Solution:
    Using a simple regular expression, you can validate the entered phone number during the guest registration. 
    The below regular expression will help you to validate the phone number and allows to register only  when the phone number is not staring with '+' or '0'. 
    ^[1-9][0-9](\d{7}|\d{8}|\d{9}|\d{10}|\d{11}|\d{12})$
    It also performs the below validations.
    only numbers are allowed.
    first digit of the entered phone number should be 1 to 9, so '+' or '0' is not allowed. 
    numbers from 0 to 9 are allowed from the second digit.
    also validates phone number length, the length of the phone number should be 9 to 14.
    Configuration:
    To add the above regex in the visitor_phone number filed, please navigate to ClearPass Guest >> Configuration >> (Pages)Guest Self-Registration >> select the self-registration page and go to Edit >> Register Page >> Form >>  select the filed visitor_phone and set the Validator to " ISRegexMatch" and enter the above regex in the Validator Argument filed as shown below.
    Note:  Edit the Validation Error as per your requirement.
    Verification
    Adding the given regex will validate the phone number and prevent the guest user from registering the phone number starts with '+' or '0'.
    Please find below the sample outputs for your reference.
    Result when phone number starts with '+' or '0'.
    Successful registration.

    Is this a Mac Preview issue?

  • Any way to validate the Mandatory field in the XML file

    Hi,
    Is there any way to validate the Mandatory field in the XML file. I created an xml type table xml_validate based on the schema and insert the XML files with statement.
    INSERT INTO xml_validate(warehouse_id,xml_file_name,warehouse_spec)
    Values (agreementid,p_filename,XMLTYPE.createXML(l_clob));
    It is validating the data types, extra tags etc but not validating the missing of the manadatory tag/value.
    Thanks in advance
    Rizly

    Hi Ants,
    Yes, I was not doing the strict validation, after searching the forum i understood that was the reason. So i did this way,
    begin
    for x in (select myColumn from myTable where WAREHOUSE_ID=41) loop
    x.myColumn .schemaValidate();
    end loop;
    end;
    The out put is:
    ORA-31154: invalid XML document
    ORA-19202: Error occurred in XML processing
    LSX-00011: internal error: LsxvPushCandidate array overflow
    ORA-06512: at "SYS.XMLTYPE", line 345
    ORA-06512: at line 3
    My i know more information about this error, especially
    LSX-00011: internal error: LsxvPushCandidate array overflow
    Thanks in advance
    Rizly

  • How to Validate the Text Field in JSF

    Hi,
    I am facing a issue to validate the text field where the below code accepts (space' ',underscore'_',pipe'|') symbol as a first character and last character.Where by it can accept in the middle.
    It should not accept special characters also. Below code is working properly for special characters.
    <tr>
    <td width="30%" align="right"><b><h:outputText id="aAccrualType" value="Accrual Type" /> </b> <span style="color:red">*</span></td>
    <td width="50%">: <h:inputText id="accrualType" value="#{accrualTypeMast.accrualType}" required="true" >          
    <t:validateRegExpr pattern="^[(a-z)||(A-Z)||(0-9)||(_)||(\s)||(/)]+$" />     
    <f:validateLength minimum="1" maximum="50"/>     
    </h:inputText>
    <h:message for="accrualType" showDetail="true" style="color:red" />
    </td>
    </tr>
    The thing is i dont have much knowledge in regular expression.
    Is there any other way to do this.
    Could anyone help me in this.
    Thanks,
    Ambika&#9786;

    This has nothing to do with JSF.
    I suggest you to read the Pattern API documentation [1]. You can easily create a small Java Application and test the regexp using String#matches() as it uses the same regexp guidelines.
    public static void main(String[] args) {
        String regexp = "^[a-z]+$";
        String value = "foo";
        boolean match = value.matches(regexp);
        System.out.println(value + " matches " + regexp + ": " + match);
    }[1] http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/Pattern.html

  • How to validate the input field

    Hi,
    I have a input form which is draged from input port of a RFC.
    in this input form i have two input fields nad submit button.
    on of this input field should always take the character values only. it should not take any numeric value
    and other input field should always take numeric value only.
    i.e how to validate this two input fields.
    regards
    srinivas

    Hi,
    U can validate input fields using javascript.Write OnClientClick function for that submit button if ur using htmlb or onClick if u r using html.Refer the follows
    http://help.sap.com/saphelp_nw70/helpdata/en/03/900e41a346ef6fe10000000a1550b0/frameset.htm
    There are two ways to achieve ur task.
    1.By checking for all alphabets.in this u need check all the alphabetic characters one by one.Refer the following
    http://www.shiningstar.net/articles/articles/javascript/javascriptvalidations.asp?ID=ROLLA
    http://www.shiningstar.net/articles/articles/javascript/checkNumeric.asp?ID=AW
    2.By using regular expressions.its very easy and a single line code.here u need to specify single expression for whole alphabets.Refer this
    http://aspzone.com/blogs/john/articles/173.aspx
    Everything has been given for validating in javascript.i hope u also validating in javascript only.
    For more details on "Regular expressions" search google.
    Regards,
    Tamil K

  • How to hide the Media type field if no video is uploaded in paglayout

    Hi,
    I am creating a custom page layout with custom content type through visual studio 2010 for sharepoint 2010.
    i need to create a field which supports to upload a video file.
    so i created a site column and added it to my content type and added to my page layout.
    <Field ID="{7F5AE2F9-C1A2-4BFD-876C-56ECFB7B0210}" Name="Video" DisplayName="Article Video" Type="MediaFieldType"  Group="Article Layout Columns" />
    <FieldRef ID="{7F5AE2F9-C1A2-4BFD-876C-56ECFB7B0210}" Name="Video"/>
    In my page layout i added the field in both edit and display mode as
       <PublishingWebControls:MediaFieldControl ID="MediaFieldControl1" FieldName="Article Video" runat="server"/>
    All is well the video is displayed and i can add video.
    My req is i need to show the video div in display mode only if video is added else it should be hidden in display mode.
    how to do that?
    Aruna

    Hi,
    According to your post, my understanding is that you want to hide the Media type field if no video uploaded.
    After the video uploaded, the HTML of the Media Type Field will be changed. We can use jQuery to detect the change and hide/show it.
    The following script for your reference:
    <script src="http://code.jquery.com/jquery-1.10.2.min.js" type="text/javascript"></script>
    <script type="text/javascript">
    $(function () {
    if($("selector")==""){
    $("divID").hide();
    </script>
    More information:
    http://msdn.microsoft.com/en-us/library/gg699337(v=vs.85).aspx
    https://api.jquery.com/hide/
    Thanks,
    Dennis Guo
    TechNet Community Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Dennis Guo
    TechNet Community Support

  • How  to validate the mandatory fields in the view in WDA?

    Dear experts,
                            Iam new to WDA. i just want to know how  to validate the mandatory fields in the view in WDA?please refer any documents for validating the mandatory fields.
    Regards,
    murthy.
    Edited by: Murthy Ganti on Jul 13, 2009 2:31 PM

    Hi,
    Firstly goto view->select the element that you want to make mandatory and set the State property to required.
    Secondly place the below code in the WDDOBEFOREACTION
    DATA: l_view_controller TYPE REF TO if_wd_view_controller.
    * Get view controller
      l_view_controller = wd_this->wd_get_api( ).
    * Check for mandatory attribute
      cl_wd_dynamic_tool=>check_mandatory_attr_on_view(
      EXPORTING view_controller  = l_view_controller
                display_messages = abap_true
    Regards,
    Radhika.

  • Unable to view Certain Phone Types in Self Service HR

    Through SSHR I am able to add all Phone Types that are enabled in HR_LOOKUPS - Work Fax, Fax, Home, Work, Other, and Cell. I am able to view them but when I select update button the next screen drops Phone Type Fax and displays other phone type numbers.. But on Oracle Prof. screen I am able to view all and perform DML Operations. Your response will be appreciated.

    Please check whether seeded SSHR page has the Fax field or not? It might not be there on the seeded page or might have been hidden through personalization.
    It is not necessary that what you see on SSHR page will be equivalent to PUI screen.
    --Shiv                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • How to validate the input field data in VC using RFC FM

    HI,
    Could any body please give me the solution for the following issue?
    When ever I enter a value in the input field of an iView, this value has to be validated from the backend BW system.  Is this validation is possible using RFC function module?
    If yes, please explain me.

    Hi Deepak,
    U can validate input fields using javascript.Write OnClientClick function for that submit button if ur using htmlb or onClick if u r using html.Refer the follows
    http://help.sap.com/saphelp_nw70/helpdata/en/03/900e41a346ef6fe10000000a1550b0/frameset.htm
    There are two ways to achieve ur task.
    1.By checking for all alphabets.in this u need check all the alphabetic characters one by one.Refer the following
    http://www.shiningstar.net/articles/articles/javascript/javascriptvalidations.asp?ID=ROLLA
    http://www.shiningstar.net/articles/articles/javascript/checkNumeric.asp?ID=AW
    2.By using regular expressions.its very easy and a single line code.here u need to specify single expression for whole alphabets.Refer this
    http://aspzone.com/blogs/john/articles/173.aspx
    Regards,
    Naren

  • How can I validate a date field in Portal Forms

    I have a date field in portal forms that I want to perform validation on to make sure it's in the proper format before being accepted (mm/dd/yyyy). How can I validate against that field?

    Hi Ben,
    I took the time to test and revise. This is code that will validate a date entry (format MM/DD/YYYY). Just paste this in the "Before the start of the form..." window of the Additional PL/SQL code section of the form. Then add validateDate(); into the onBlur event window of the field in question. Replace the CYCLE_END_DATE with the field name in question.
    HTP.P('
    <SCRIPT LANGUAGE=javascript>
    function validateDate() {
    var ddObj;
    var mmObj;
    var yyObj;
    var day;
    var mon;
    var year;
    var field_val;
    var field_name;
    for (var j=0; j < document.forms[0].elements.length; j++) {
    field_name = document.forms[0].elements[j].name;
    field_val = document.forms[0].elements[j].value;
    if (field_name.substring(field_name.indexOf(''DEFAULT.'') + 8, field_name.lastIndexOf(''.01'')) == ''CYCLE_END_DATE'') {
    var delimPos = field_val.search(/\//i);
    if (delimPos < 0)
    alert(''Invalid date entry! Please enter in MM/DD/YYYY format. '' +
    ''e.g, Dec 21, 2003 would be entered as 12/21/2003'');
    else
    if (field_val.length != 10)
    alert(''Invalid date entry! Please Please enter in MM/DD/YYYY format. '' +
    ''e.g, Jan 1, 2003 would be entered as 01/01/2003'');
    else {
    month = field_val.substring(0, field_val.indexOf(''/''));
    day = field_val.substring(field_val.indexOf(''/'') + 1, field_val.lastIndexOf(''/''));
    year = field_val.substring(field_val.lastIndexOf(''/'') + 1, 10);
    /* Need to subtract 1 from value because in Javascript, January begins with 0
    and ends with 11 for December */
    month = month - 1;
    ddObj = new Date(year, month, day);
    mmObj = new Date(year, month, day);
    yyObj = new Date(year, month, day);
    if (ddObj.getDate(ddObj.setDate(day)) != day)
    alert(''Invalid day!'');
    if (mmObj.getMonth(mmObj.setMonth(month)) != month)
    alert(''Invalid month!'');
    if (mmObj.getYear(mmObj.setYear(year)) != year)
    alert(''Invalid year!'');
    </SCRIPT>
    ');

Maybe you are looking for