查看: 780|回复: 8
|
请问这个JAVASCRIPT的FUNCTIONS如何把它加在一个FUNCTION里????
[复制链接]
|
|
但人家打他们的生日日期在这个BOX时,它会看看那个日期是否正确,如果不对就有ALERT BOX出来
以下是我那个JAVA SCRIPT 的CODES, 我用了三个FUNCTIONS来写, 我想问如有要把三个FUNCTION的CODES放进一个,那要怎么写
example:
function checkDOB()
{
var wholedate=document.REG.DOB.value
var cmon=wholedate.substr(0,2)
var cdate=wholedate.substr(3,2)
var cyear=wholedate.substr(6,4)
var leapyear =9
if (cyear%400==0)
{
leapyear=1
}
else (if(cyear%100==0))
{
leapyear =0
}
else if (cyear%4==0)
{
leapyear=1
}
else leapyear=0
}
function noleapyear()
var fulldate = document.reg.DOB.value
var month = fulldate.substr(0,2)
var day = fulldate.substr(3,2)
if (month==02 && day> 28)
{
alert ("no leap year then no Feb >28")
}
function yesleapyear()
{
var fulldate = document.REG.DOB.value
var month = fulldate.substr(0,2)
var day = fulldate.substr(3,2)
if (month==02 && >29)
{
alert ("leap year Feb no > 29")
}
}
谢谢 |
|
|
|
|
|
|
|
发表于 6-12-2007 10:16 PM
|
显示全部楼层
懒惰看。。。。
给你看我的好了
30/02/2008 <-这是不会过的哦 |
|
|
|
|
|
|
|
发表于 6-12-2007 10:17 PM
|
显示全部楼层
var cmon=wholedate.substr(0,2)
var cdate=wholedate.substr(3,2)
var cyear=wholedate.substr(6,4)
这样写很危险下。。。 |
|
|
|
|
|
|
|

楼主 |
发表于 10-12-2007 07:47 AM
|
显示全部楼层
谢谢楼上的, 我是要拿来做FORM用的, 就是说不要有BUTTON按的
就如: 你打13在月份那边,它就会出现ALERT了
谢谢 |
|
|
|
|
|
|
|
发表于 10-12-2007 08:48 PM
|
显示全部楼层
|
|
|
|
|
|
|

楼主 |
发表于 10-12-2007 11:33 PM
|
显示全部楼层
原帖由 小陈陈 于 10-12-2007 08:48 PM 发表 
...
<HTML>
<HEAD>
<SCRIPT>
<!-- Hide from older browsers
function checkDOB()
{
var wholedate=document.REG.DOB.value
var cmon=wholedate.substr(0,2)
var cdate=wholedate.substr(3,2)
var cyear=wholedate.substr(6,4)
var leapyear =9
if (cyear%400==0)
{
leapyear=1
}
else (if(cyear%100==0))
{
leapyear =0
}
else if (cyear%4==0)
{
leapyear=1
}
else leapyear=0
}
function noleapyear()
var fulldate = document.reg.DOB.value
var month = fulldate.substr(0,2)
var day = fulldate.substr(3,2)
if (month==02 && day> 28)
{
alert ("no leap year then no Feb >28"
}
function yesleapyear()
{
var fulldate = document.REG.DOB.value
var month = fulldate.substr(0,2)
var day = fulldate.substr(3,2)
if (month==02 && >29)
{
alert ("leap year Feb no > 29"
}
}
}
function DateToday() {
var Today=new Date();
var ThisDay=Today.getDate();
var ThisMonth=Today.getMonth()+1;
var ThisYear=Today.getFullYear();
return ThisMonth+"/"+ThisDay+"/"+ThisYear;
}
function StartForm() {
document.REG.FORMDATE.value=DateToday();
document.REG.FIRSTNAME.focus();
}
function CheckOther() {
if(document.REG.PHYSICIAN.selectedIndex==7) {
document.REG.OTHERNAME.value=prompt("Enter name of physician", "Name" ;
}
document.REG.ACT.focus();
}
function APGAR(field) {
if(field.value==0 || field.value==1 || field.value==2) {
var A=eval(document.REG.ACT.value);
var P=eval(document.REG.PULSE.value);
var G=eval(document.REG.GRIMACE.value);
var AP=eval(document.REG.APP.value);
var R=eval(document.REG.RESP.value);
} else {
alert("You must enter a 0, 1, or 2" ;
field.focus();
}
}
function Check_Data() {
if(document.REG.CONSENT.checked==true) {
alert("Form completed successfully" ;
return true;
} else {
alert("You still need parental consent" ;
return false;
}
}
//Stop hiding -->
</SCRIPT>
</HEAD>
<BODY BGCOLOR="#008080" TEXT=WHITE >
<FORM name="REG" >
<CENTER>
<IMG SRC="Logo.gif" WIDTH=450 HEIGHT=75 ALT="Downstate Medical Center">
<TABLE CELLSPACING=3 CELLPADDING=5>
<!--- Study Title--->
<TR>
<TD ALIGN=CENTER COLSPAN=3>
<H1><FONT FACE="Arial,Helvetica">Neonatal Feeding Study</FONT></H1>
</TD>
</TR>
<!--- Field showing the current date --->
<TR>
<TD COLSPAN=3 ALIGN=RIGHT>
Date: <INPUT NAME=FORMDATE SIZE=10 MAXLENGTH=10>
</TD>
</TR>
<!--- Fields containing the first and last name of the patient --->
<TR>
<TD>
1) Name (first, last):
</TD>
<TD>
<INPUT NAME=FIRSTNAME></TD><TD><INPUT NAME=LASTNAME>
</TD>
</TR>
<!--- Medical record number field --->
<TR>
<TD>
2) Medical Record #:
</TD>
<TD>
<INPUT NAME=MEDRECNO SIZE=10 MAXLENGTH=10>
</TD>
</TR>
<!--- Date of birth field --->
<TR>
<TD>
3) Date of birth:
</TD>
<TD>
<INPUT NAME=DOB VALUE="mm/dd/yyyy" SIZE=10 MAXLENGTH=10>
</TD>
</TR>
<!--- Selection list with physician names and a field for names not in list --->
<TR>
<TD>
4) Physician:
</TD>
<TD>
<SELECT NAME=PHYSICIAN >
<OPTION VALUE="Alexander">Dr. Dorrick Alexander
<OPTION VALUE="Alleyne">Dr. Damian Alleyne
<OPTION VALUE="Au">Dr. Chun Yiu Au
<OPTION VALUE="Bacchus">Dr. Stephen Bacchus
<OPTION VALUE="Baptiste">Dr. Sheldon Baptiste
<OPTION VALUE="Brown">Dr. Veniece Brown
<OPTION VALUE="Cobos">Dr. Hernan Cobos
<OPTION VALUE="Other">Other
</SELECT>
</TD>
</TR>
<!--- Physician names not in the list --->
<TR>
<TD>
If other (specify):
</TD>
<TD>
<INPUT NAME=OTHERNAME>
</TD>
</TR>
<!--- Activity component of the APGAR score --->
<TR>
<TD ROWSPAN=6 VALIGN=TOP>
5) 1 Minute APGAR Score:
</TD>
<TD>
Activity
</TD>
<TD>
<INPUT NAME=ACT VALUE=0 SIZE=1 MAXLENGTH=1 >
</TD>
</TR>
<!--- Pulse component of the APGAR score --->
<TR>
<TD>
Pulse
</TD>
<TD>
<INPUT NAME=PULSE VALUE=0 SIZE=1 MAXLENGTH=1 >
</TD>
</TR>
<!--- Grimace component of the APGAR score --->
<TR>
<TD>
Grimace (Reflex, Irritability)
</TD>
<TD>
<INPUT NAME=GRIMACE VALUE=0 SIZE=1 MAXLENGTH=1 >
</TD>
</TR>
<!--- Appearance component of the APGAR score --->
<TR>
<TD>
Appearance (Skin Color)
</TD>
<TD>
<INPUT NAME=APP VALUE=0 SIZE=1 MAXLENGTH=1 >
</TD>
</TR>
<!--- Respiration component of the APGAR score --->
<TR>
<TD>
Respiration
</TD>
<TD>
<INPUT NAME=RESP VALUE=0 SIZE=1 MAXLENGTH=1 >
</TD>
</TR>
<!--- Total APGAR score --->
<TR>
<TD>
<B>TOTAL</B>
</TD>
<TD>
<INPUT NAME=TOTAL VALUE=0 SIZE=2 MAXLENGTH=2>
</TD>
</TR>
<!--- Birth weight field --->
<TR>
<TD>
6) Birth weight (gms):
</TD>
<TD>
<INPUT NAME=BWGT SIZE=6>
</TD>
</TR>
<!--- Parental consent checkbox --->
<TR>
<TD>
7) Parental Consent (required):
</TD>
<TD>
<INPUT TYPE=CHECKBOX NAME=CONSENT>
</TD>
</TR>
<!--- Form registration and reset buttons --->
<TR>
<TD COLSPAN=3 ALIGN=CENTER>
<INPUT TYPE=SUBMIT VALUE="Register">
<INPUT TYPE=RESET VALUE="Reload" >
</TD>
</TR>
</TABLE>
</CENTER>
< > lease submit all questions regarding this form or the NICU feeding study
to <FONT COLOR="#FFFF00">Dr. Menaouer Djellali, Department of Pediatrics, ext.
1234</FONT>.</P>
</FORM>
</BODY>
</HTML>
[ 本帖最后由 Pool 于 10-12-2007 11:37 PM 编辑 ] |
|
|
|
|
|
|
|

楼主 |
发表于 10-12-2007 11:36 PM
|
显示全部楼层
这才是我的完整的CODES,但它无效
 |
|
|
|
|
|
|
|
发表于 11-12-2007 11:00 PM
|
显示全部楼层
|
|
|
|
|
|
|

楼主 |
发表于 12-12-2007 12:43 AM
|
显示全部楼层
我说的那个方法可能很麻烦, 还是借用你的CODES
谢谢你 |
|
|
|
|
|
|
| |
本周最热论坛帖子
|