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 9 of 9
  1. #1
    New Coder
    Join Date
    Oct 2002
    Location
    Mumbai,India
    Posts
    67
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Strange problem validation of date

    I ahve 2 subsequent date fields
    say dt1 and dt2

    I have date validation routine and calling it on "onblur" event
    so as to validate the date field before ficusing on next field

    How I am calling it " blur(this) "

    The default value stored in date field is today's date is "dd-mm-yyyy"
    The program is goding in lioop

    when wrong date is entered it say apprpropriate mesage

    However the control (focus) is on next field(even though the date is incorrect'


    why should it happen ?? please help

    I am callind same fuction in same program to validate dat (which is first field) and set focus is occuring properly



    The html code in which I am using date validation para

    <tr bgcolor="#FFFFFF">
    <td height="49" class="text-b12">
    <div align="center">
    <input name="containerno0" type="text" class="text-b12" id="containerno0" size="12" maxlength="12" onBlur="chkcontainerno(this)" >
    <input name="containers" type="hidden" id="containers">
    </div></td>
    <td> <div align="center">
    <select name="containersize0" class="text-b12">
    <option value="1" class="text-b12">6 '</option>
    <option value="2" class="text-b12">10'</option>
    <option value="3" class="text-b12">20'</option>
    <option value="4" class="text-b12">40'</option>
    <option value="5" class="text-b12">40 HC</option>
    <option value="6" class="text-b12">20 HC</option>
    </select>
    </div></td>
    <td> <div align="center" class="text-b12">
    <select name="containertype0" class="text-b12">
    <option value="1">OT</option>
    <option value="2">TR</option>
    <option value="3">GP</option>
    <option value="4">RF</option>
    </select>
    </div></td>
    <td> <input name="pikupdate0" type="text" class="text-b12" id="pikupdate0" value="<? echo "dd-mm-yyyy" ?>" size="12" maxlength="12" onblur="return chkdate(this)" >
    <input name="pikupdate0_ymd" type="hidden" id="pikupdate0_ymd">
    . </td>
    <td width="72"> <input name="stuffdate0" type="text" class="text-b12" id="stuffdate0" value="<? echo $dmy ?>" size="12" maxlength="12" onblur="return chkdate(this)" ></td>
    <td> <input name="packages0" type="text" id="packages0" size="5" maxlength="5" class="text-b12" onBlur="chkpkgs(this)" ></td>
    <td><input name="movedondate0" type="text" class="text-b12" id="movedondate0" value="<? echo $dmy ?>" size="12" maxlength="12" onblur="return chkdate(this)"></td>
    <td><input name="loadondate0" type="text" class="text-b12" id="loadondate0" value="<? echo $dmy ?>" size="12" maxlength="12" onblur="return chkdate(this)"></td>
    <td><div align="center">
    <input name="vessalno0" type="text" class="text-b12" id="vessalno0" size="8" maxlength="8" onBlur="" >
    </div></td>
    <td width="72">
    <input type="button" name="Submit42" value="Add More" onClick="addLine()" ></td>
    <td width="8">&nbsp;</td>
    </tr>

  • #2
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    eeer you forgot to show us the javascript code...

    Anyway... try puting the object.focus() code line after the alert() message.
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #3
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Try using onchange as opposed to onblur....

    .....Willy

  • #4
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    I suggest you to not to use onblur to validate fields as users may experience endless alert loop in some browsers or not focusing at all as you're experiencing right now. Validate on form onsubmit event instead, it's user-friendlier.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #5
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    What about onkeyup?
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #6
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    onkeyup is going to call the validation code on every stroke, not good.

    Validation should be done on the submit, I have found that users see that as less fustrating and they are not being force fed.

    Eric
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]

  • #7
    New Coder
    Join Date
    Oct 2002
    Location
    Mumbai,India
    Posts
    67
    Thanks
    0
    Thanked 0 Times in 0 Posts

    It is recommnded to use on submit

    It is recommended t use validation only on submit

  • #8
    New Coder
    Join Date
    Oct 2002
    Location
    Mumbai,India
    Posts
    67
    Thanks
    0
    Thanked 0 Times in 0 Posts

    It is recommnded to use on submit

    I have concluded to use validation only on submit

  • #9
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    It is recommended t use validation only on submit
    With some exceptions, maybe...
    For instance... a limitator of maximum allowed number of characters folowed by a 'counter' (for user to see when he is about to reach the limit). It is obvious to me that kind of validator should be done sequential, thus it should be handled by a "local" event, such as onkeyup or onchange.
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*


  •  

    Posting Permissions

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