...

View Full Version : check that last character is not a period.



ventura
10-13-2003, 08:30 PM
how can i check that if an input field ends in a period (.), i throw up an alert.

thanks.

Basscyst
10-13-2003, 08:51 PM
Here you Go:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<script type="text/javascript" language="javascript">
function formVal(){
str=document.getElementById('box').value;
checkp=str.charAt(str.length-1);
if(checkp=="."){
alert("No Period There Please");
}

}
</script>
<title></title>
</head>
<body>
<form><input type="text" id="box"> <input type="button" value=
"Submit" onclick="formVal();"></form>
</body>
</html>


Basscyst



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum