webForumDet fria alternativet

Hjälp med att sätta ihopp kod

JavaScript

2 svar · 135 visningar · startad av Wiklund!!

Medlem sedan juli 2002549 inlägg
Frågan#1

Är helt värdelös på javascript. Skulle nån kunna hjälpa mig att satta ihopp dessa 3 koder till 1? Skulle vilja ha det i den ordning som det är här nedanför.

[kod]
<script language="javaScript">
function mess()
{
if (document.post.username.value.length<3)
{
alert("Your username cannot be less than 3 characters!");
document.post.username.focus();
return false;
} else if (document.post.fname.value=="")
{
alert("You forgot to enter your first name!");
return false;
} else if (document.post.lname.value=="")
{
alert("You forgot to enter your last name!");
return false;
} else if (document.post.city.value.length<3)
{
alert("The name of the city where you live cannot be less than 3 characters!");
document.post.city.focus();
return false;
}
}
</script>

<script language="javaScript">
function mess()
{
var pass1 = document.post.password1.value;
var pass2 = document.post.password2.value;

if (pass1 != pass2)
{
    alert("Passwords did not match!");
    return false;
}

if (pass1.length \< 4)
{
    alert("Your password cannot be less than 4 characters in length!");
    return false;
}

return true; // Jag som antar...

}
</script>

<script language="javaScript">
function mess()
{
if (document.post.code.value.length<5)
{
alert("Your active code cannot be less than 5 characters!");
document.post.code.focus();
return false;
}
}
</script>

Medlem sedan nov. 20017 144 inlägg
#2

Så här menar du?:

<script language="javascript" type="text/javascript"> 
function mess() 
{ 
if (document.post.username.value.length<3) 
{ 
alert("Your username cannot be less than 3 characters!"); 
document.post.username.focus(); 
return false; 
} else if (document.post.fname.value=="") 
{ 
alert("You forgot to enter your first name!"); 
return false; 
} else if (document.post.lname.value=="") 
{ 
alert("You forgot to enter your last name!"); 
return false; 
} else if (document.post.city.value.length<3) 
{ 
alert("The name of the city where you live cannot be less than 3 characters!"); 
document.post.city.focus(); 
return false; 
} 
} 

function mess() 
{ 
var pass1 = document.post.password1.value; 
var pass2 = document.post.password2.value; 

if (pass1 != pass2) 
{ 
alert("Passwords did not match!"); 
return false; 
} 

if (pass1.length < 4) 
{ 
alert("Your password cannot be less than 4 characters in length!"); 
return false; 
} 

return true; // Jag som antar... 
} 
 
function mess() 
{ 
if (document.post.code.value.length<5) 
{ 
alert("Your active code cannot be less than 5 characters!"); 
document.post.code.focus(); 
return false; 
} 
} 
</script>
Medlem sedan dec. 20025 483 inlägg
#3
<script type="text/javascript">
function mess(){
	if (document.post.username.value.length<3){
		alert("Your username cannot be less than 3 characters!");
		document.post.username.focus();
		return false;
	}
	else if (document.post.fname.value==""){
		alert("You forgot to enter your first name!");
		return false;
	}
	else if (document.post.lname.value==""){
		alert("You forgot to enter your last name!");
		return false;
	}
	else if (document.post.city.value.length<3){
		alert("The name of the city where you live cannot be less than 3 characters!");
		document.post.city.focus();
		return false;
	}
	else if (document.post.password1.value != document.post.password2.value){
		alert("Passwords did not match!");
		return false;
	}
	else if (document.post.password1.value.length<4){
		alert("Your password cannot be less than 4 characters in length!");
		return false;
	}
	else if (document.post.code.value.length<5){
		alert("Your active code cannot be less than 5 characters!");
		document.post.code.focus();
		return false;
	}
}
</script>

:)

271 ms totalt · 4 externa anrop · v20260731065814-full.6fe65c25
135 ms — deklarationer (db)
0 ms — hämta statistik (cache)
130 ms — hämta tråd, inlägg och bilagor (db)
137 ms — ändringar (db)