Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reformat user's input to match SQL Server acceptable format

Status
Not open for further replies.

BrendaD

Programmer
Jan 26, 2001
25
CA
My users want to enter the time in the 24 hour clock format:

ie: 1212 vs 12:12

SQL Server will not accept 1212 as a time format.

Is there a way to add the colon onSubmit so SQL Server will accept it?

Thanks, Brenda
 
Hi,
If you are looking for help to convert the user's entry to the required format in javascript then you can do this:

Call this function on submit which will convert the input in the form "1212" to "12:12" and put it into a hidden variable. You can use the hidden variable to insert into the database.
<script language=&quot;javascript&quot;>
function fnSubmit()
{
stest=document.frmTest.txtTime.value;
stest1=stest.substring(0,2);
stest2=stest.substring(2,4);
stime=stest1 + &quot;:&quot; + stest2;
document.frmTest.htxtTime.value=stime;
}

</script>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top