Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
184
rated 0 times [  185] [ 1]  / answers: 1 / hits: 7737  / 10 Years ago, wed, june 18, 2014, 12:00:00

Hey I know its been asked before but those forums don't have the answer as per my code!



<a href=#  class=button dark
value=Register
onclick=return regformhash(this.form,
this.form.username,
this.form.email,
this.form.password,
this.form.confirmpwd); >Register</a>


In the code above it gives me an error Uncaught SyntaxError:




Unexpected token ILLEGAL in thw chrome console.




It works perfectly using input type= button but in that case the predefined styles dark button don't work. I don't want to mess with the CSS so could anyone tell me how to fix this?



P.S. No the quotes don't have a problem, any help would be appreciated! Thanks.



UPDATE: the form code as well:



<form action=<?php echo esc_url($_SERVER['PHP_SELF']); ?> 
method=post
name=registration_form>
First name: (required)<input type=text name=firstname/>
<br>
Last name: (required) <input type=text name=lastname/>
<br>
Company: <input type=text name=company />
<br>
Contact number: <input type=text name=contact />
<br>
Username: <input type='text'
name='username'
id='username' /><br>
Email: <input type=text name=email id=email /><br>
<br>
Password: <input type=password
name=password
id=password/><br>
<br>
Confirm password: <input type=password
name=confirmpwd
id=confirmpwd /><br>
<a href=javascript:regformhash(this.form,
this.form.username,
this.form.email,
this.form.password,
this.form.confirmpwd); class=button dark
value=Register
>Register</a>
</form>

More From » html

 Answers
40

You can try like this...



just pass the form and then access other fields in the function like this..



<a href=#  class=button dark
value=Register
onclick=return regformhash(document.getElementById('myform')
); >Register</a>



function regformhash(frm){
alert(frm.username.value)
return false;
}


myform is ID of the form


[#44493] Monday, June 16, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
yosefleod

Total Points: 113
Total Questions: 100
Total Answers: 115

Location: Egypt
Member since Tue, May 3, 2022
2 Years ago
;