|
|
| Author |
Message |
che100
Joined: 28 Feb 2004 Posts: 20 Location: Lebanon
|
Posted: Mon Mar 01, 2004 1:03 am Post subject: alert dialog box |
|
|
<HTML><HEAD>
<TITLE>Alert Dialog Box</TITLE>
<SCRIPT LANGUAGE="JavaScript">
<!-- Hide from JS-Impaired Browsers
function testIt(){
str=document.ug.ly.value;
/* First, if no entry, give an alert
and then move cursor to form
element with focus() call. */
if (str.length<1){
alert("Please enter a user name so"
+" that we can continue");
document.ug.ly.focus();
}
else{
/* Next, if entry too short, give
an alert and then move cursor to
form element with focus() call,
and then a select() call to
highlight it. */
if (str.length!=6){
alert("Please enter a user name that"
+" is exactly 6 characters long.");
document.ug.ly.focus();
document.ug.ly.select();
}
else{
/* Process the rest of form here. Just
so you can see it accepts 6 letter
names, the next line is included in
this script. */
alert("You typed exactly six letters!"
+" The name you entered is "+str);
}
}
}
// End Hiding -->
</SCRIPT>
</HEAD>
<BODY BGCOLOR="white">
<CENTER><P>
<B>JavaScript Alert Dialog Box</B>
<P><TABLE BORDER=0 WIDTH=490>
<TR><TD>Click the Submit button without typing a name, then type a name less than 6 characters, then one longer than 6 characters and finally one exactly six characters long, clicking on the Submit button after each.</TD></TR>
</TABLE>
<P><FORM NAME="ug">
Six Character User Name: <INPUT TYPE="text" NAME="ly">
<INPUT TYPE="button" NAME="but" VALUE=" Submit " onClick="testIt()">
</FORM>
</BODY>
</HTML> |
|
| Back to top |
|
 |
sam Banned
Joined: 01 Mar 2004 Posts: 51 Location: IL
|
Posted: Mon Mar 01, 2004 1:24 pm Post subject: |
|
|
Howtos _________________
 |
|
| Back to top |
|
 |
macabist Banned
Joined: 01 Mar 2004 Posts: 35
|
Posted: Mon Mar 01, 2004 1:33 pm Post subject: |
|
|
isn't it simpler to write
window.alert();
? |
|
| Back to top |
|
 |
sam Banned
Joined: 01 Mar 2004 Posts: 51 Location: IL
|
Posted: Mon Mar 01, 2004 1:38 pm Post subject: |
|
|
yes i think so! _________________
 |
|
| Back to top |
|
 |
macabist Banned
Joined: 01 Mar 2004 Posts: 35
|
Posted: Mon Mar 01, 2004 1:43 pm Post subject: |
|
|
| alright |
|
| Back to top |
|
 |
|