insert data with validation

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Noorain
    New Member
    • Mar 2008
    • 57

    insert data with validation

    Sir
    I face a problem.please help me. my problem is

    i have to insert phone no. or a/c id in same field. i have to use two text box. one for phone no. another for a/c id. if i enter phone no. then a/c id disable. no input accept in a/c id textbox. same as phone no., when i entry a/c id then no phone no. entry allowed. On time only one entry allow. another is disable.

    Please help me.

    Thanks
  • hsriat
    Recognized Expert Top Contributor
    • Jan 2008
    • 1653

    #2
    Do that with JavaScript.[html]<input type="text" name="phone" id="ph" onkeyup="docume nt.getElementBy Id('ac').disabl ed = !!this.value.le ngth;">
    <input type="text" name="account" id="ac" onkeyup="docume nt.getElementBy Id('ph').disabl ed = !!this.value.le ngth;">[/html]

    Comment

    • ronverdonk
      Recognized Expert Specialist
      • Jul 2006
      • 4259

      #3
      This is a JS question and belongs in the JavaScript forum, so I will move it to that.

      Ronald

      Comment

      • dasrasmikant
        New Member
        • Jan 2008
        • 30

        #4
        very intrestng..
        But sir why we are setting its value to
        Code:
        !!this.value.length;
        what does it means.

        Comment

        • hsriat
          Recognized Expert Top Contributor
          • Jan 2008
          • 1653

          #5
          Originally posted by dasrasmikant
          very intrestng..
          But sir why we are setting its value to
          Code:
          !!this.value.length;
          what does it means.
          You mean the double NOT?
          It will work without the double NOT too. Its not mandatory.

          Double NOT just makes sure the result is boolean.
          !!0 returns false
          !!n returns true (where n is any number)
          Also works on strings.

          Comment

          • dasrasmikant
            New Member
            • Jan 2008
            • 30

            #6
            Originally posted by hsriat
            You mean the double NOT?
            It will work without the double NOT too. Its not mandatory.

            Double NOT just makes sure the result is boolean.
            !!0 returns false
            !!n returns true (where n is any number)
            Also works on strings.
            Thanks for the response.
            But its not working on single not.
            if the purpose of its to set a boolean value then
            why its not working in like below.

            <input type="text" name="phone" id="ph" onkeyup="docume nt.getElementBy Id('ac').disabl ed = true;">
            <input type="text" name="account" id="ac" onkeyup="docume nt.getElementBy Id('ph').disabl ed = true;">

            Comment

            • dasrasmikant
              New Member
              • Jan 2008
              • 30

              #7
              Originally posted by hsriat
              You mean the double NOT?
              It will work without the double NOT too. Its not mandatory.

              Double NOT just makes sure the result is boolean.
              !!0 returns false
              !!n returns true (where n is any number)
              Also works on strings.
              Thanks for the response.
              But its not working on single not.
              if the purpose of its to set a boolean value then
              why its not working in like below.

              Code:
              <input type="text" name="phone" id="ph" onkeyup="document.getElementById('ac').disabled = true;">
              <input type="text" name="account" id="ac" onkeyup="document.getElementById('ph').disabled = true;">

              Comment

              • hsriat
                Recognized Expert Top Contributor
                • Jan 2008
                • 1653

                #8
                What are you trying to do? What is the purpose?

                If you got a similar problem, tell me that.

                Comment

                • malav123
                  New Member
                  • Feb 2008
                  • 217

                  #9
                  HI,
                  call the javascript function for both textboxes...lik e,
                  Code:
                  txtDayphone.Attributes.Add("Onkeypress", "return formatPhoneNumber(this)")
                  and check there if one of the textbox gets keypress at the same time remaining text box gets disable to data entry...... i think by implementing this your problem will be solved...


                  -malav.
                  Last edited by gits; Mar 31 '08, 11:54 AM. Reason: remember to use CODE TAGS!!!

                  Comment

                  • gits
                    Recognized Expert Moderator Expert
                    • May 2007
                    • 5390

                    #10
                    Originally posted by malav123
                    HI,
                    call the javascript function for both textboxes...lik e,
                    Code:
                    txtDayphone.Attributes.Add("Onkeypress", "return formatPhoneNumber(this)")
                    ...
                    this is no javascript-code ... it seems to be some .NET stuff ... please don't mess different things here ... to set an attribute to a node the regular javascript-dom-method is:

                    [CODE=javascript]node.setAttribu te('attrib_name ', 'attrib_value') ;[/CODE]
                    to attach event-handlers you have different possibilities ... write it to the node directly:

                    [HTML]<input type="button" onclick="alert( 'clicked me');" value="click me"/>[/HTML]
                    or use addEventListene r() and attachEvent() for this, or set the event-handler-properties like:

                    [CODE=javascript]node.onclick = function() { alert('somethin g') };[/CODE]

                    and: Use code tags when posting Source Code!!!!!

                    kind regards

                    Comment

                    • malav123
                      New Member
                      • Feb 2008
                      • 217

                      #11
                      Originally posted by gits
                      this is no javascript-code ... it seems to be some .NET stuff ... please don't mess different things here ... to set an attribute to a node the regular javascript-dom-method is:

                      [CODE=javascript]node.setAttribu te('attrib_name ', 'attrib_value') ;[/CODE]
                      to attach event-handlers you have different possibilities ... write it to the node directly:

                      [HTML]<input type="button" onclick="alert( 'clicked me');" value="click me"/>[/HTML]
                      or use addEventListene r() and attachEvent() for this, or set the event-handler-properties like:

                      [CODE=javascript]node.onclick = function() { alert('somethin g') };[/CODE]

                      and: Use code tags when posting Source Code!!!!!

                      kind regards





                      No gits, my intense is not to giving .net stuff here but i just giving logic to solve the problem of current post...
                      the code for javascript for this post is quite simple that's why i have not write here....

                      Comment

                      • gits
                        Recognized Expert Moderator Expert
                        • May 2007
                        • 5390

                        #12
                        you posted that repeatedly here in the javascript-forum ... and since .NET stuff is NOT javascript you either should explicitly mark the code as NON-javascript-code with a comment or a note or just translate it to javascript ... there is no reason to write code in another language in a specific forum ... i wouldn't even post a java-solution in the .NET forum and say thats the logic ... translate it yourself ... that is NOT appropriate and i will delete further posts of you here with such behaviour ... remember this!

                        regards,
                        MODERATOR

                        Comment

                        Working...