javascript - Validating time entered into textbox -


i have textbox in user can enter time (eg: 01:00) , drop down box entering am/pm fields. (since am/pm field used, 12-hour time format used.)

the text box allows max entry of 5 chars (eg: 01:00).

  1. how can set 3rd char default colon :, user has enter time.
  2. how check if time entered user numeric or not?.
  3. autocomplete feature: example, if user enters 1 automatically set 01:00
  4. javascript validations 12-hour format. eg: if user enters 13:00 should change 01:00
  5. how can append text box time values am/pm value selected in drop down box?.
  6. once values appended, automatically populate text box (text box 2) result. eg: 01:00 + pm should set 01:00p in new text box (text box 2).

any appreciated.

  1. better have textbox size , maxlength of 2 named "txthours", colon label (span tag) , textbox named "txtminutes". easier manage.
  2. instead of checking, have onkeypress code returns false when key pressed not number allowing digits.
  3. best done in onblur event, if value less 10 add 0 in beginning.
  4. pretty simple script, though not trivial - use % operator.
  5. not sure mean? append where?
  6. document.getelementbyid("textbox2").value = strappendedtext;

that's general idea, let me know if need implementing best give try first.


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -