Malak Malak - 1 year ago 86
HTML Question

onClick() function can't trigger javascript code

I have a small problem. I tried to add an

function to my submit button but my JavaScript doesn't run. I dont't know where the error is :(
When I put the code inside
property the alert dialog works fine.

<script type="text/javascript">
fuction login() {

<form action="javascript:void(0);" method="">
<fieldset class="clearfix">
<p><span class="fontawesome-user"></span><input type="text" value="إسم المستخدم أو الأيميل" name="username" onBlur="if(this.value == '') this.value = 'إسم المستخدم أو الأيميل'" onFocus="if(this.value == 'إسم المستخدم أو الأيميل') this.value = ''" required/></p>
<!-- JS because of IE support; better: placeholder="Username" -->

<p><span class="fontawesome-lock"></span><input type="password" value="كلمة السر" name="psw" onBlur="if(this.value == '') this.value = 'كلمة السر'" onFocus="if(this.value == 'كلمة السر') this.value = ''" required/> </p>
<!-- JS because of IE support; better: placeholder="Password" -->

<p><input type="submit" value="Login" onClick="login();" /></p>

Answer Source

I see you have made a simple spelling of "function" above.

Please change it into function login(){...

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download