PDA

View Full Version : Resolved Multiple Inputs Form Question



theflyingminstrel
03-05-2009, 11:07 PM
Hi I wanted to know how I might be able to apply this to multiple text boxes.

For some reason it only lets me attach it to one on the page.

Thank you



<html>
<head>
<meta name="generator" content="HTML Tidy for Linux/x86 (vers 1 September 2005), see www.w3.org" />
<title>sample page</title>
<script type="text/javascript">
//<![CDATA[
function verify(frm) {
var element = document.getElementById('txt').value;
element = element.replace(/[^0-9,\.]/,"");
document.getElementById("txt").value = element;
}
//]]>
</script>
</head>
<body>
<form action=""><input type="text" onkeyup="verify(this.id);" name="txt" id="txt" /></form>
</body>
</html>

Nile
03-05-2009, 11:16 PM
Replace:


function verify(frm) {
var element = document.getElementById('txt').value;
element = element.replace(/[^0-9,\.]/,"");
document.getElementById("txt").value = element;
}


With:



function verify(frm) {
var element = document.getElementById(frm).value;
element = element.replace(/[^0-9,\.]/,"");
document.getElementById(frm).value = element;
}

theflyingminstrel
03-05-2009, 11:51 PM
That's amazing, thanks so much!

Nile
03-06-2009, 12:11 AM
Glad to help you theflyingminstrel!

It seems your topic is solved... Please set the status to resolved.. To do this:
Go to your first post ->
Edit your first post ->
Click "Go Advanced" ->
Then in the drop down next to the title, select "RESOLVED"