Announcement

Collapse
No announcement yet.

Phone Number Checking

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Phone Number Checking

    Is their a way I could make a item that would check to make sure 10 digits were entered in the phone number field. Similar to the way that the zip code field checks for at least 5 digits.

    How would I go about doing this?
    Affordable Small Business Web Site Design| Find Texas Web Sites | Krunk Rock | Web Ready Audio |

    #2
    Yes. If you've got a copy of the standalone scripts that came with Mia a while back you can see the info in there.
    Best,
    Pamela

    Consultant / Developer / Trainer
    Contributing Editor to Practical Ecommerce
    Author of the Official Guides for Miva Merchant
    pamelahazelton.com

    Comment


      #3
      something like

      <MvASSIGN NAME = "l.phone" VALUE = "{ glosub( l.phone, '+', '' ) }">
      <MvASSIGN NAME = "l.phone" VALUE = "{ glosub( l.phone, '/', '' ) }">
      <MvASSIGN NAME = "l.phone" VALUE = "{ glosub( l.phone, '(', '' ) }">
      <MvASSIGN NAME = "l.phone" VALUE = "{ glosub( l.phone, ')', '' ) }">
      <MvASSIGN NAME = "l.phone" VALUE = "{ glosub( l.phone, '-', '' ) }">
      <MvASSIGN NAME = "l.phone" VALUE = "{ glosub( l.phone, 'x', '' ) }">
      <MvASSIGN NAME = "l.phone" VALUE = "{ glosub( l.phone, '.', '' ) }">
      <MvASSIGN NAME = "l.phone" VALUE = "{ glosub( l.phone, ' ', '' ) }">

      <MvIF EXPR = "{ NOT isdigit( l.phone ) }">
      <MvASSIGN NAME = "l.valid" VALUE = 0>
      </MvIF>

      <MvIF EXPR = "{ len( l.phone ) NE 10 }">
      <MvASSIGN NAME = "l.valid" VALUE = 0>
      </MvIF>
      <MvELSE>
      <MvASSIGN NAME = "l.valid" VALUE = "1">
      </MvIF>

      but not sure what you mean by "make it an item"
      Bruce Golub
      Phosphor Media - "Your Success is our Business"

      Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
      phosphormedia.com

      Comment


        #4
        What I mean by and Item is adding a new item with the code that would do the checking and assigning that to the ACAD screen.

        My thinking was similar, then I would just compile the script and add it as an item.

        But would something like this work directly inside the customer fields tab template:
        Code:
        <mvt:item name="fonts" param="body_font">
        <mvt:if expr="NOT g.Customer_ShipPhone_Invalid">
        <b>Phone Number:</b>
        <mvt:else>
        <mvt:if expr="{len(g.Customer_ShipPhone NE 10)}">
        <font color="red">
        <b>Phone Number:</b>
        </font>
        </mvt:if>
        </mvt:if>
        </mvt:item>
        </td><td align="left" valign="middle">
        <mvt:item name="fonts" param="body_font">
        <input type="text" name="Customer_ShipPhone" size=25 value="&mvte:global:Customer_ShipPhone;">
        </mvt:item>
        Affordable Small Business Web Site Design| Find Texas Web Sites | Krunk Rock | Web Ready Audio |

        Comment


          #5
          no because the test has to occur on submit....and otherwise, when first reaching the screen the test would be invalid so the Phone Number would appear in red.

          You would need to do quite a bit of hacking to get the phone number to test to 10 digits.

          ...and for what...most folks would just put 1231231233...phone numbers should never be require IMO for online sales...I (and just about every online user I know) would not enter their real phone number)...but that is just MO
          Bruce Golub
          Phosphor Media - "Your Success is our Business"

          Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
          phosphormedia.com

          Comment


            #6
            I'm not trying to require the phone number, just check that if they have input a number that it is 10 digits.

            The zip code field checks for at least 5 digits by miva default correct?

            If I were to take your code and compile it and install it as an Item would it work?

            This is for a clients site, and I actually have the same opinion but, trying to please the client as well.
            Affordable Small Business Web Site Design| Find Texas Web Sites | Krunk Rock | Web Ready Audio |

            Comment


              #7
              It would be easier to convince the client otherwise...no, it would not work...you would have to intercept the post from the initiall account page, do your checks...and do all of the other checks as well, then display the result on a custom page...at least as far as I know...
              Bruce Golub
              Phosphor Media - "Your Success is our Business"

              Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
              phosphormedia.com

              Comment


                #8
                Is it possible to even get the miva 5 source files (.mv) so that I could try and implement this function? I've already downloaded the Miva5 source, but they are all .mvc.

                Where do I begin to attempt to retrieve the posted info and check it.
                Affordable Small Business Web Site Design| Find Texas Web Sites | Krunk Rock | Web Ready Audio |

                Comment


                  #9
                  If you want, one of our developers whipped up a system module that does this (show off)...we could probably let you use it...although we couldn't support it for free.
                  Bruce Golub
                  Phosphor Media - "Your Success is our Business"

                  Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
                  phosphormedia.com

                  Comment


                    #10
                    Validate form posts with system modules

                    Hello Blakerockstar,

                    Originally posted by blakerockstar
                    Is it possible to even get the miva 5 source files (.mv) so that I could try and implement this function? I've already downloaded the Miva5 source, but they are all .mvc.
                    MIVA makes available a selection of the source from the MIVA Merchant 5 application. http://smallbusiness.miva.com/products/mmlsk/ Such API documentation as is already available is here: http://smallbusiness.miva.com/support/docs/api/. (Everyone agrees that there needs to be more.) I encourage you to continue asking questions here, because a lot of knowledgeable folk enjoy answering.

                    Originally posted by blakerockstar

                    Where do I begin to attempt to retrieve the posted info and check it.
                    To intercept the phone number submission, a system module will be more suitable than an item. It sounds as if Bruce already has a solution for you, but for your and other's benefit, here is how I would go about creating the module you need.

                    I think of needing to write code to accomplish 4 main tasks:

                    1) Intercept the Action

                    A system module will allow you to insert instructions for MIVA Merchant to execute upon receiving the form post containing the information you are interested in. MIVA Merchant will consult the SystemModule_Action function from each assigned system module whenever it, Merchant, detects a value for Action in the request or form post.

                    View source on or consult the template for the form you are interested in and check the hidden input field named ?Action?. You can then surround your phone validation instructions with a conditional based on this value. E.g.

                    <MvFUNCTION NAME = "SystemModule_Action" PARAMETERS = "module var, action" STANDARDOUTPUTLEVEL = "">

                    <MvIf expr=?{l.action EQ ?XXYY?}?>
                    [Code to validate phone number]
                    </MvIf>

                    <MvFUNCRETURN VALUE = "{1}">
                    </MvFUNCTION>


                    2) Set the screen/destination

                    You will notice another hidden input in the form, one called ?Screen?. This is the variable that signals Merchant which screen to build in response to the form post. If Screen = PROD, Merchant will execute the instructions to build the ?Product? screen. If Screen = OSEL, Merchant will execute the instructions to build the ?Checkout: Shipping/Payment Selection? screen.

                    You will probably want to signal Merchant to display a different screen next instead. In cases of invalid entries, you normally want Merchant to display the same screen over again. So if you are validating a submission made from the ?Checkout: Customer Information? (OCST) screen, you will want Merchant to return to that screen:

                    <MvAssign name=?g.Screen? value=?OCST?>



                    3) Write a message for display

                    You can use the Messages item to display text explaining to the user why they are back at the same page again/

                    <MvAssign name=?l.ok? value=?{
                    [g.Module_Library_Utilities].Message_Error(?Please check the phone number you entered.?)
                    }>

                    4) Set the invalidity flag.

                    You can also set the invalidity flag, so that Merchant renders the prompt beside the phone number in red, to highlight it.

                    <MvAssign name=?g.ShipPhone_Invalid? value=?{1}?>


                    So you will end up with something like:


                    <MvFUNCTION NAME = "SystemModule_Action" PARAMETERS = "module var, action" STANDARDOUTPUTLEVEL = "">

                    <MvIf expr=?{l.action EQ ?XXYY?}?>
                    [Code to validate phone number]
                    <MvIf expr=?{NOT l.valid}?>
                    <MvAssign name=?l.ok? value=?{
                    [g.Module_Library_Utilities].Message_Error(?Please check the phone number you entered.?)
                    }>
                    <MvAssign name=?g.ShipPhone_Invalid? value=?{1}?>
                    <MvAssign name=?g.Screen? value=?OCST?>
                    </MvIf>
                    </MvIf>

                    <MvFUNCRETURN VALUE = "{1}">
                    </MvFUNCTION>


                    A final point, you may want to have SystemModule_Action return 0 when l.action = ?XXYY? A return of zero will signal MIVA Merchant to skip the instructions it would normally follow in response to Action = ?XXYY? and move on to the instructions about building the screen.

                    HTH,

                    Mark

                    Comment


                      #11
                      What about Javascript as a solution? It would be very easy to make sure that the user input only numbers and that strlen is >= 10. Of course this isn't the best solution because disabling javascript will get you around it, but its not a bad one either.

                      To make this work, you want to edit the <form> and add an onsubmit="javascript:validate();" (or something similiar).

                      Comment


                        #12
                        Re: Phone Number Checking

                        First sorry to have replied such an old post.
                        This post is right the info what I am looking for at this moment, specially Mark Hughes's post.
                        My question is :
                        when I set SystemModule_Action to return value 0, Miva goes to :
                        Fatal Error
                        Miva Merchant has encountered a fatal error and is unable to continue. The following information may assist you in determining the cause of the error:

                        Error Code: MER-00001 Description: <b>Unknown Error</b><br><br>&nbsp;&nbsp;Action = <br>&nbsp;&nbsp;Screen = PROD

                        Comment


                          #13
                          Re: Phone Number Checking

                          Just for later viewer's sake, the solution is to return -1 in SystemModule_Action instead of 0
                          Last edited by yanping; 05-14-10, 01:25 PM.

                          Comment

                          Working...
                          X