Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Jul 2009
    Posts
    152
    Thanks
    8
    Thanked 0 Times in 0 Posts

    prevent the others type using jquery

    Code:
    1 ,<input id="14sq-und-0-value" size="12" maxlength="10" class="form-text" type="text">
    
    2 ,<input id="510sq-und-0-value" size="12" maxlength="10" class="form-text" type="text">
    
    3 ,<input id="1119sq-und-0-value"  size="12" maxlength="10" class="form-text" type="text">
    
    4, <input id="20jsq-und-0-value" size="12" maxlength="10" class="form-text" type="text">
    
    5 ,<input id="oneyear-und-0-value"  maxlength="10" class="form-text" type="text">
    
    
    6 ,<input id="twoyear-und-0-value"  maxlength="10" class="form-text" type="text">
    
     7 ,<input id="threeyear-und-0-value" size="12" maxlength="10" class="form-text" type="text">
    
    8  <input id="vpssq-und-0-value" size="12" maxlength="10" class="form-text" type="text">
    
    9 <input id="500zh-und-0-value"  size="12" maxlength="10" class="form-text" type="text">
    
    10  <input id="1000zh-und-0-value" size="12" maxlength="10" class="form-text" type="text">
    
     11  <input id="1500zh-und-0-value" size="12" maxlength="10" class="form-text" type="text">

    now, i want to do, if the editor type content to 1, 2, 3 4 input box and finished namely the 1 ,2,3 4have value , then he can't type anything to the rest.

    if the 5,6,7, input box has value. then can't type anything to the rest.

    if the 8, input box has value. then can't type anything to the rest.

    if the9,10,11, input box has value. then can't type anything to the rest.

  • #2
    Banned
    Join Date
    Feb 2011
    Posts
    2,699
    Thanks
    13
    Thanked 395 Times in 395 Posts
    You could put an onchange event handler on each textbox which then checks which textboxes have data entered. You then enable/disable text boxes accordingly.

    Basically, I would use an if-else if block.

    btw - what happens if the user enters data in boxes 1,5,6,7 in that order. Do you then delete the data in box 1?
    Last edited by bullant; 05-19-2011 at 06:53 AM.

  • #3
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,910
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    Before you start,

    id="510sq-und-0-value"

    an id must begin with a letter, not a number.

    "if the 5,6,7, input box has value. then can't type anything to the rest."
    What if only 5 and 6 are filled in? Can the user enter into box 9?

    What if the user enters a single space into a box?

    You need to specify your requirement more precisely.

    onchange will only work when the focus is transferred to another form element. Onblur would be better.


    All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.
    Last edited by Philip M; 05-19-2011 at 07:10 AM.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •