B
Barnes
Hi,
Can anyone please tell me how I can use the replace method to replace
a character if it occures in more than one textbox without having to
write separate function for each textbox.
The code below is the basic way to use the replace method but it only
allows for one textbox.
I'm sure I need a loop in there but I'm not sure how to use that
without affecting the replace method.
Any help would be greatly appreciated!
---------------------------------------------
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<script language="javascript">
function stringReplace(form) {
var replaceStr = form.textfield1.value
var pattern = /\'/g;
form.textfield1.value = replaceStr.replace(pattern, "''");
}
</script>
</head>
<body>
<form name="form1" method="post" action="JStest_redirect.asp">
<p>fname:
<input type="text" name="textfield1" size="20">
</p>
<p>lname:
<input type="text" name="textfield2" size="20">
</p>
<p>
<input onclick="return stringReplace(form)" type="submit"
name="Submit" value="Submit">
</p>
</form>
</body>
</html>
Can anyone please tell me how I can use the replace method to replace
a character if it occures in more than one textbox without having to
write separate function for each textbox.
The code below is the basic way to use the replace method but it only
allows for one textbox.
I'm sure I need a loop in there but I'm not sure how to use that
without affecting the replace method.
Any help would be greatly appreciated!
---------------------------------------------
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<script language="javascript">
function stringReplace(form) {
var replaceStr = form.textfield1.value
var pattern = /\'/g;
form.textfield1.value = replaceStr.replace(pattern, "''");
}
</script>
</head>
<body>
<form name="form1" method="post" action="JStest_redirect.asp">
<p>fname:
<input type="text" name="textfield1" size="20">
</p>
<p>lname:
<input type="text" name="textfield2" size="20">
</p>
<p>
<input onclick="return stringReplace(form)" type="submit"
name="Submit" value="Submit">
</p>
</form>
</body>
</html>