Jump to content

Nub Form Name Question


savagenoob

Recommended Posts

OK... I cannot code javascript for dog poop, but I am trying to use Tigra Form Validator to validate form fields prior to submission. When I try to change the form name it doesnt validate the fields like its supposed to. I changed the form name on the form, and in the script... the form name does not show up anywhere else and I am going crazy... Here is the code with 'login' as the form name, which works, when I change the name it doesnt...

<table cellpadding="3" cellspacing="1" border="0" width="100%">

<tr>

	<td class="intd"><br>



<form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="POST" name="login" onsubmit="return v.exec()">

<table cellpadding="0" cellspacing="0" border="0" width="300" align="center">

<tr>

<td width="8"><img src="images/blue1_l.gif" alt="" width="8" height="23" border="0"></td>

<td background="images/blue1_m.gif" nowrap>Register New User</td>

<td width="8"><img src="images/blue1_r.gif" alt="" width="8" height="23" border="0"></td>

<td background="images/table_bg.gif" width="100%"> </td>

<td background="images/table_bg.gif"><img src="images/pixel.gif" width="10" height="1" border="0"></td>

</tr>

<tr>

<td background="images/line_l.gif"><img src="images/pixel.gif" border="0"></td>

<td colspan="3">

<img src="images/pixel.gif" width="1" height="10" border="0"><br>

<table cellpadding="0" cellspacing="0" border="0" width="100%"><tr><td bgcolor="#DBEAF5">

	<table cellspacing="1" cellpadding="2" border="0" width="100%">

	<tr bgcolor="#ffffff">

		<td id="t_uname" width="10%">User Name:</td>

		<td><input type="text" name="uname" size="10" class="ctrl"></td>

	</tr>

	<tr bgcolor="#ffffff"> 

		<td id="t_email"> Email:<span class="inputHighlighted">*</span></td>

		<td><input type="text" name="email" size="35" class="ctrl"></td>

	</tr>

	<tr bgcolor="#ffffff"> 

		<td id="t_password"> Password:<span class="inputHighlighted">*</span></td>

		<td><input type="password" name="pass" size="35" class="ctrl"></td>

	</tr>

	<tr bgcolor="#ffffff"> 

		<td id="t_password_copy" nowrap> Password copy:<span class="inputHighlighted">*</span> </td>

		<td><input type="password" name="pass_copy" size="35" class="ctrl"></td>

	</tr>

	</table></td></tr></table>

<img src="images/pixel.gif" width="1" height="10" border="0"><br>

<div align="center" id="error_registration" style="display: block;"></div>

</td>

<td background="images/line_r.gif"><img src="images/pixel.gif" border="0"></td>

</tr>

<tr>

<td colspan="5" bgcolor="#4682B4"><img src="images/pixel.gif" width="1" height="1" border="0"></td>

</tr>

<tr>

<td colspan="5" align="right">

<table cellpadding="0" cellspacing="0" border="0">

<tr>

	<td class="btn" width="1"><input type="image" src="images/submit1.gif" alt="" width="79" height="22" border="0" name="Submit"></td>

</tr>

</table>

</td>

</tr>

</table>
<script>

// form fields description structure

var a_fields = {

'uname' : {

	'l': 'Name',  // label

	'r': false,    // required

	'f': 'alpha',  // format (see below)

	't': 't_uname',// id of the element to highlight if input not validated



	'm': null,     // must match specified form field

	'mn': 2,       // minimum length

	'mx': null       // maximum length

},

'email' : {'l':'E-mail','r':true,'f':'email','t':'t_email'},

'pass' : {'l':'Password','r':true,'f':'alphanum','t':'t_password','m':'pass_copy'},

'pass_copy' : {'l':'Password copy','r':true,'f':'alphanum','t':'t_password_copy'}

},

o_config = {

'to_disable' : ['Submit'],

'alert' : 1

}



// validator constructor call

var v = new validator('login', a_fields, o_config)



</script>
</form>

validator() is defined in validator.js which is an include file... 'login' is the form name you pass to validator() but you should be able to change this name.... I know this is something simple Im missing.

Link to comment
https://forums.phpfreaks.com/topic/147679-nub-form-name-question/
Share on other sites

fixed code:

var a_fields = {

   'uname' : {

      'l': 'Name',  

      'r': false,   
      'f': 'alpha',  
      't': 't_uname',
      

      'm': null,    

      'mn': 2,      

      'mx': null      

   },

   'email' : {'l':'E-mail','r':true,'f':'email','t':'t_email'},

   'pass' : {'l':'Password','r':true,'f':'alphanum','t':'t_password','m':'pass_copy'},

   'pass_copy' : {'l':'Password copy','r':true,'f':'alphanum','t':'t_password_copy'}

},

o_config = {

   'to_disable' : ['Submit'],

   'alert' : 1

};




var v = new validator('login', a_fields, o_config);

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.