webForumDet fria alternativet

Inga bindesträck

1 svar · 168 visningar · startad av skyman

skymanMedlem sedan juli 20012 450 inlägg
#1

Hej,
jag vill inte att man ska kunna skriva i bindesträck i lösenordsrutan.

 
regexp="^[A-Za-z0-9]+$";
if(document.form.password.value.search(regexp)==-1){
	alert("Lösenordet får bara innehlla A-Za-z0-9.");
                document.form.password.focus();

	return false;
}

Detta fungerar inte...

dectgapMedlem sedan sep. 20021 655 inlägg
#2

Jag får det till att fungera.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>

<head>
<title>xxx</title>

<script type="text/javascript">

function regga(){
 regexp="^[A-Za-z0-9]+$";
 if(document.forms[0].password.value.search(regexp)==-1){
	alert("Lösenordet får bara innehlla A-Za-z0-9.");
                document.form.password.focus();

	return false;
 } else {
	alert("Bra");
 }
}

</script>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>

<body>

<form>
<input type="text" name="password" />
<button onclick="regga()">Klick</button>
</form>

</body>

</html>
127 ms totalt · 3 externa anrop · v20260731065814-full.30151723
0 ms — hämta forumlista (cache)
0 ms — hämta statistik (cache)
124 ms — hämta tråd, inlägg och bilagor (db)