/    Sign up×
Community /Pin to ProfileBookmark

Problem with calling function within button

The code below is supposed to take an input in a textbox and upon the click of a button call a function to check the input.
I cannot get this to work at all the text box and button appear but the code for the function appears on the page and the button press does nothing.
Any advice here please ?

// Creates text box for bank sort code to be entered
<p>The layout used in this input is three pairs of numbers seperated by -. Thanks for taking the time to read this!</p>

<input type=”text” name=”Bank_Sort_Code” maxlength=”8″ />

<p><input type=”button” value=”Click here” onClick=”validateBankNo();”></p>

<script language=”javascript” type=”text/javascript”>
function validateBankNo()
{
if(ereg(‘^[0-9]{2}-[0-9]{2}-[0-9]{2}$’, $Bank_Sort_Code))
return True;
else
return false;

}
</script>

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@mityaAug 04.2009 — Works for me. Does your script really appear after the HTML, or is that just how it appears in the example you posted here?
Copy linkTweet thisAlerts:
@El_DuderenoauthorAug 07.2009 — The code is as posted here.

The text box is on the screen as is the button, but the function code is shown on the screen.This should surely be hidden.
Copy linkTweet thisAlerts:
@ryanlundAug 07.2009 — try putting the javascript in the page head tags....
×

Success!

Help @El_Dudereno spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...