I am working on a few forms that need to have the enter button disabled. With JavaScript I can acheieve this. The easiest example I found for disableing submission of a form when the enter button is pressed is given below.
But inserting the
into every single individual text box in the site seems unnecessarily laborious...
Is there a way I can include JavaScript in CSS documents?
Can I make it so everyone one my text boxes on any form in the website has enter disabled through CSS, or a javascript include file with out having to add
to every single text box?
Thanks again
:>
I don't know the answer but my good friend Google does.
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "[URL unfurl="true"]http://www.w3.org/TR/html4/strict.dtd">[/URL]
<html>
<head>
<title>new document</title>
<script type="text/javascript">
function noenter() {
return !(window.event && window.event.keyCode == 13); }
</script>
<style type="text/css">
</style>
</head>
<body>
<form name="f">
<input type="text" name="t1" value="" onkeypress="return noenter()" /><br />
<input type="text" name="t2" value="" onkeypress="return noenter()" /><br />
<input type="text" name="t3" value="" onkeypress="return noenter()" /><br />
<input type="text" name="t4" value="" onkeypress="return noenter()" /><br />
<input type="text" name="t5" value="" onkeypress="return noenter()" /><br />
<input type="text" name="t6" value="" onkeypress="return noenter()" /><br />
<input type="submit" name="s" />
</form>
</body>
</html>
But inserting the
Code:
onkeypress="return noenter()"
Is there a way I can include JavaScript in CSS documents?
Can I make it so everyone one my text boxes on any form in the website has enter disabled through CSS, or a javascript include file with out having to add
Code:
onkeypress="return noenter()"
Thanks again
:>
I don't know the answer but my good friend Google does.