EDN Admin
Well-known member
Hey Guys....<br/>
So i am using validation for my registration page. I have set it that the register button wont be clickable (i.e it is disabled) untill all fields meet validation reguirements (i.e username longer than 5 digits etc...)<br/>
<br/>
This was working fine with the following code:<br/>
<br/>
<div style="background-color:white; border:1px solid #7f9db9; line-height:100%!important; font-family:Courier New; font-size:11px
<table cellspacing="0" cellpadding="0" style="width:99%; margin:2px 0px; border-collapse:collapse; border-bottom:0px solid #eeeeee; background-color:#ffffff; border-width:0px
<colgroup><col style=" </colgroup>
<tbody>
<tr>
<td><span style="font-size:11px <span style="color:blue public<span style="font-size:11px <span style="color:blue string<span style="font-size:11px <span style="color:blue this<span style="font-size:11px [<span style="color:blue string<span style="font-size:11px propertyName] </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 { </td>
</tr>
<tr>
<td> <span style="color:blue get<span style="font-size:11px </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 { </td>
</tr>
<tr>
<td> <span style="color:blue string<span style="font-size:11px validationResult = <span style="color:blue null<span style="font-size:11px ; </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 </td>
</tr>
<tr>
<td> <span style="color:green //used bool to check if user name is clicked activite valdiaiton. if not dont. i.e label error wont display<span style="font-size:11px </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 <span style="color:blue switch<span style="font-size:11px (propertyName) </td>
</tr>
<tr>
<td> { </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 <span style="color:blue case<span style="font-size:11px <span style="color:blue "FirstName"<span style="font-size:11px : </td>
</tr>
<tr>
<td> validationResult = FnameValidation(); //this will check requirements of firstname
<br/>
</td>
</tr>
<tr>
<td style="background-color:#f7f7f7 <span style="color:blue break<span style="font-size:11px ; </td>
</tr>
<tr>
<td> <span style="color:blue case<span style="font-size:11px <span style="color:blue "Surname"<span style="font-size:11px : </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 validationResult = SnameValidation(); //this will check requirements of surname etc...</td>
</tr>
<tr>
<td> <span style="color:blue break<span style="font-size:11px ; </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 <span style="color:blue case<span style="font-size:11px <span style="color:blue "Email"<span style="font-size:11px : </td>
</tr>
<tr>
<td> validationResult = EmailValidation(); </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 <span style="color:blue break<span style="font-size:11px ; </td>
</tr>
<tr>
<td> <span style="color:blue case<span style="font-size:11px <span style="color:blue "Username"<span style="font-size:11px : </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 validationResult = UnameValidation(); </td>
</tr>
<tr>
<td> <span style="color:blue break<span style="font-size:11px ; </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 </td>
</tr>
<tr>
<td> <span style="color:blue default<span style="font-size:11px : </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 <span style="color:blue throw<span style="font-size:11px <span style="color:blue new<span style="font-size:11px ApplicationException(<span style="color:blue "Error - Property being validated is unknown."<span style="font-size:11px ); </td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 } </td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 <span style="color:blue return<span style="font-size:11px validationResult; </td>
</tr>
<tr>
<td> } </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 } </td>
</tr>
</tbody>
</table>
So basically it worked fine however I have set errors to appear if the validation is incorrect. Problem being the errors displayed whenever the screen loaded. So I had to refactor the above code (to the code down below) which uses bools which only
activate when that particlar field is clicked. So for example it wont display the particular error message until the gamer clicks on the field.<br/>
<br/>
<div style="background-color:white; border:1px solid #7f9db9; line-height:100%!important; font-family:Courier New; font-size:11px
<table cellspacing="0" cellpadding="0" style="width:99%; margin:2px 0px; border-collapse:collapse; border-bottom:0px solid #eeeeee; background-color:#ffffff; border-width:0px
<colgroup><col style=" </colgroup>
<tbody>
<tr>
<td><span style="font-size:11px <span style="color:blue public<span style="font-size:11px <span style="color:blue string<span style="font-size:11px <span style="color:blue this<span style="font-size:11px [<span style="color:blue string<span style="font-size:11px propertyName] </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 { </td>
</tr>
<tr>
<td> <span style="color:blue get<span style="font-size:11px </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 { </td>
</tr>
<tr>
<td> <span style="color:blue string<span style="font-size:11px validationResult = <span style="color:blue null<span style="font-size:11px ; </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 </td>
</tr>
<tr>
<td> <span style="color:green //used bool to check if user name is clicked activite valdiaiton. if not dont. i.e label error wont display<span style="font-size:11px </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 <span style="color:blue switch<span style="font-size:11px (propertyName) </td>
</tr>
<tr>
<td> { </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 <span style="color:blue case<span style="font-size:11px <span style="color:blue "FirstName"<span style="font-size:11px : </td>
</tr>
<tr>
<td> <span style="color:blue if<span style="font-size:11px (FnameValidate) //if user clicks on firstname
field run fname validation test on text entered (same for below)<br/>
</td>
</tr>
<tr>
<td style="background-color:#f7f7f7 { </td>
</tr>
<tr>
<td> validationResult = FnameValidation(); </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 } </td>
</tr>
<tr>
<td> <span style="color:blue break<span style="font-size:11px ; </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 <span style="color:blue case<span style="font-size:11px <span style="color:blue "Surname"<span style="font-size:11px : </td>
</tr>
<tr>
<td> <span style="color:blue if<span style="font-size:11px (SnameValidate) </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 { </td>
</tr>
<tr>
<td> validationResult = SnameValidation(); </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 } </td>
</tr>
<tr>
<td> <span style="color:blue break<span style="font-size:11px ; </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 <span style="color:blue case<span style="font-size:11px <span style="color:blue "Email"<span style="font-size:11px : </td>
</tr>
<tr>
<td> <span style="color:blue if<span style="font-size:11px (EmailValidate) </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 { </td>
</tr>
<tr>
<td> validationResult = EmailValidation(); </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 } </td>
</tr>
<tr>
<td> <span style="color:blue break<span style="font-size:11px ; </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 <span style="color:blue case<span style="font-size:11px <span style="color:blue "Username"<span style="font-size:11px : </td>
</tr>
<tr>
<td> <span style="color:blue if<span style="font-size:11px (UnameValidate) </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 { </td>
</tr>
<tr>
<td> validationResult = UnameValidation(); </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 } </td>
</tr>
<tr>
<td> <span style="color:blue break<span style="font-size:11px ; </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 <span style="color:blue case<span style="font-size:11px <span style="color:blue "Roles"<span style="font-size:11px : </td>
</tr>
<tr>
<td> <span style="color:blue if<span style="font-size:11px (RolesValidate) </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 { </td>
</tr>
<tr>
<td> <span style="color:green // validationResult = selectRoles();<span style="font-size:11px </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 } </td>
</tr>
<tr>
<td> <span style="color:blue break<span style="font-size:11px ; </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 <span style="color:blue default<span style="font-size:11px : </td>
</tr>
<tr>
<td> <span style="color:blue throw<span style="font-size:11px <span style="color:blue new<span style="font-size:11px ApplicationException(<span style="color:blue "Error - Property being validated is unknown."<span style="font-size:11px ); </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 </td>
</tr>
<tr>
<td> } </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 </td>
</tr>
<tr>
<td> <span style="color:blue return<span style="font-size:11px validationResult; </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 } </td>
</tr>
<tr>
<td> } </td>
</tr>
</tbody>
</table>
<br/>
<br/>
The problem being with this that the Register button enables and disables itself as every field is entered. it runs this enable/disable function for every field. i only want it to run when all the fields are valid. not seperately. The code
for this is seen below: <br/>
<br/>
<div style="background-color:white; border:1px solid #7f9db9; line-height:100%!important; font-family:Courier New; font-size:11px
<table cellspacing="0" cellpadding="0" style="width:99%; margin:2px 0px; border-collapse:collapse; border-bottom:0px solid #eeeeee; background-color:#ffffff; border-width:0px
<colgroup><col style=" </colgroup>
<tbody>
<tr>
<td><span style="font-size:11px <span style="color:blue private<span style="font-size:11px <span style="color:blue void<span style="font-size:11px ValidateProperties() </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 { </td>
</tr>
<tr>
<td> <span style="color:blue foreach<span style="font-size:11px (<span style="color:blue bool<span style="font-size:11px isValid <span style="color:blue in<span style="font-size:11px validProperties.Values) <span style="color:green //problem being here with foreach<span style="font-size:11px </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 { </td>
</tr>
<tr>
<td> <span style="color:blue if<span style="font-size:11px (!isValid) </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 { </td>
</tr>
<tr>
<td> <span style="color:blue this<span style="font-size:11px .AllPropertiesValid = <span style="color:blue false<span style="font-size:11px ; </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 <span style="color:blue return<span style="font-size:11px ; </td>
</tr>
<tr>
<td> } </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 } </td>
</tr>
<tr>
<td> <span style="color:blue this<span style="font-size:11px .AllPropertiesValid = <span style="color:blue true<span style="font-size:11px ; </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 </td>
</tr>
<tr>
<td> } </td>
</tr>
</tbody>
</table>
So it returns TRUE foreach. Is there a way i can change this to only work FOR ALL
<br/>
<br/>
Thanks again for any help.<br/>
View the full article
So i am using validation for my registration page. I have set it that the register button wont be clickable (i.e it is disabled) untill all fields meet validation reguirements (i.e username longer than 5 digits etc...)<br/>
<br/>
This was working fine with the following code:<br/>
<br/>
<div style="background-color:white; border:1px solid #7f9db9; line-height:100%!important; font-family:Courier New; font-size:11px
<table cellspacing="0" cellpadding="0" style="width:99%; margin:2px 0px; border-collapse:collapse; border-bottom:0px solid #eeeeee; background-color:#ffffff; border-width:0px
<colgroup><col style=" </colgroup>
<tbody>
<tr>
<td><span style="font-size:11px <span style="color:blue public<span style="font-size:11px <span style="color:blue string<span style="font-size:11px <span style="color:blue this<span style="font-size:11px [<span style="color:blue string<span style="font-size:11px propertyName] </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 { </td>
</tr>
<tr>
<td> <span style="color:blue get<span style="font-size:11px </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 { </td>
</tr>
<tr>
<td> <span style="color:blue string<span style="font-size:11px validationResult = <span style="color:blue null<span style="font-size:11px ; </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 </td>
</tr>
<tr>
<td> <span style="color:green //used bool to check if user name is clicked activite valdiaiton. if not dont. i.e label error wont display<span style="font-size:11px </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 <span style="color:blue switch<span style="font-size:11px (propertyName) </td>
</tr>
<tr>
<td> { </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 <span style="color:blue case<span style="font-size:11px <span style="color:blue "FirstName"<span style="font-size:11px : </td>
</tr>
<tr>
<td> validationResult = FnameValidation(); //this will check requirements of firstname
<br/>
</td>
</tr>
<tr>
<td style="background-color:#f7f7f7 <span style="color:blue break<span style="font-size:11px ; </td>
</tr>
<tr>
<td> <span style="color:blue case<span style="font-size:11px <span style="color:blue "Surname"<span style="font-size:11px : </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 validationResult = SnameValidation(); //this will check requirements of surname etc...</td>
</tr>
<tr>
<td> <span style="color:blue break<span style="font-size:11px ; </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 <span style="color:blue case<span style="font-size:11px <span style="color:blue "Email"<span style="font-size:11px : </td>
</tr>
<tr>
<td> validationResult = EmailValidation(); </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 <span style="color:blue break<span style="font-size:11px ; </td>
</tr>
<tr>
<td> <span style="color:blue case<span style="font-size:11px <span style="color:blue "Username"<span style="font-size:11px : </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 validationResult = UnameValidation(); </td>
</tr>
<tr>
<td> <span style="color:blue break<span style="font-size:11px ; </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 </td>
</tr>
<tr>
<td> <span style="color:blue default<span style="font-size:11px : </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 <span style="color:blue throw<span style="font-size:11px <span style="color:blue new<span style="font-size:11px ApplicationException(<span style="color:blue "Error - Property being validated is unknown."<span style="font-size:11px ); </td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 } </td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 <span style="color:blue return<span style="font-size:11px validationResult; </td>
</tr>
<tr>
<td> } </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 } </td>
</tr>
</tbody>
</table>
So basically it worked fine however I have set errors to appear if the validation is incorrect. Problem being the errors displayed whenever the screen loaded. So I had to refactor the above code (to the code down below) which uses bools which only
activate when that particlar field is clicked. So for example it wont display the particular error message until the gamer clicks on the field.<br/>
<br/>
<div style="background-color:white; border:1px solid #7f9db9; line-height:100%!important; font-family:Courier New; font-size:11px
<table cellspacing="0" cellpadding="0" style="width:99%; margin:2px 0px; border-collapse:collapse; border-bottom:0px solid #eeeeee; background-color:#ffffff; border-width:0px
<colgroup><col style=" </colgroup>
<tbody>
<tr>
<td><span style="font-size:11px <span style="color:blue public<span style="font-size:11px <span style="color:blue string<span style="font-size:11px <span style="color:blue this<span style="font-size:11px [<span style="color:blue string<span style="font-size:11px propertyName] </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 { </td>
</tr>
<tr>
<td> <span style="color:blue get<span style="font-size:11px </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 { </td>
</tr>
<tr>
<td> <span style="color:blue string<span style="font-size:11px validationResult = <span style="color:blue null<span style="font-size:11px ; </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 </td>
</tr>
<tr>
<td> <span style="color:green //used bool to check if user name is clicked activite valdiaiton. if not dont. i.e label error wont display<span style="font-size:11px </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 <span style="color:blue switch<span style="font-size:11px (propertyName) </td>
</tr>
<tr>
<td> { </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 <span style="color:blue case<span style="font-size:11px <span style="color:blue "FirstName"<span style="font-size:11px : </td>
</tr>
<tr>
<td> <span style="color:blue if<span style="font-size:11px (FnameValidate) //if user clicks on firstname
field run fname validation test on text entered (same for below)<br/>
</td>
</tr>
<tr>
<td style="background-color:#f7f7f7 { </td>
</tr>
<tr>
<td> validationResult = FnameValidation(); </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 } </td>
</tr>
<tr>
<td> <span style="color:blue break<span style="font-size:11px ; </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 <span style="color:blue case<span style="font-size:11px <span style="color:blue "Surname"<span style="font-size:11px : </td>
</tr>
<tr>
<td> <span style="color:blue if<span style="font-size:11px (SnameValidate) </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 { </td>
</tr>
<tr>
<td> validationResult = SnameValidation(); </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 } </td>
</tr>
<tr>
<td> <span style="color:blue break<span style="font-size:11px ; </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 <span style="color:blue case<span style="font-size:11px <span style="color:blue "Email"<span style="font-size:11px : </td>
</tr>
<tr>
<td> <span style="color:blue if<span style="font-size:11px (EmailValidate) </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 { </td>
</tr>
<tr>
<td> validationResult = EmailValidation(); </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 } </td>
</tr>
<tr>
<td> <span style="color:blue break<span style="font-size:11px ; </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 <span style="color:blue case<span style="font-size:11px <span style="color:blue "Username"<span style="font-size:11px : </td>
</tr>
<tr>
<td> <span style="color:blue if<span style="font-size:11px (UnameValidate) </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 { </td>
</tr>
<tr>
<td> validationResult = UnameValidation(); </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 } </td>
</tr>
<tr>
<td> <span style="color:blue break<span style="font-size:11px ; </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 <span style="color:blue case<span style="font-size:11px <span style="color:blue "Roles"<span style="font-size:11px : </td>
</tr>
<tr>
<td> <span style="color:blue if<span style="font-size:11px (RolesValidate) </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 { </td>
</tr>
<tr>
<td> <span style="color:green // validationResult = selectRoles();<span style="font-size:11px </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 } </td>
</tr>
<tr>
<td> <span style="color:blue break<span style="font-size:11px ; </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 <span style="color:blue default<span style="font-size:11px : </td>
</tr>
<tr>
<td> <span style="color:blue throw<span style="font-size:11px <span style="color:blue new<span style="font-size:11px ApplicationException(<span style="color:blue "Error - Property being validated is unknown."<span style="font-size:11px ); </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 </td>
</tr>
<tr>
<td> } </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 </td>
</tr>
<tr>
<td> <span style="color:blue return<span style="font-size:11px validationResult; </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 } </td>
</tr>
<tr>
<td> } </td>
</tr>
</tbody>
</table>
<br/>
<br/>
The problem being with this that the Register button enables and disables itself as every field is entered. it runs this enable/disable function for every field. i only want it to run when all the fields are valid. not seperately. The code
for this is seen below: <br/>
<br/>
<div style="background-color:white; border:1px solid #7f9db9; line-height:100%!important; font-family:Courier New; font-size:11px
<table cellspacing="0" cellpadding="0" style="width:99%; margin:2px 0px; border-collapse:collapse; border-bottom:0px solid #eeeeee; background-color:#ffffff; border-width:0px
<colgroup><col style=" </colgroup>
<tbody>
<tr>
<td><span style="font-size:11px <span style="color:blue private<span style="font-size:11px <span style="color:blue void<span style="font-size:11px ValidateProperties() </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 { </td>
</tr>
<tr>
<td> <span style="color:blue foreach<span style="font-size:11px (<span style="color:blue bool<span style="font-size:11px isValid <span style="color:blue in<span style="font-size:11px validProperties.Values) <span style="color:green //problem being here with foreach<span style="font-size:11px </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 { </td>
</tr>
<tr>
<td> <span style="color:blue if<span style="font-size:11px (!isValid) </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 { </td>
</tr>
<tr>
<td> <span style="color:blue this<span style="font-size:11px .AllPropertiesValid = <span style="color:blue false<span style="font-size:11px ; </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 <span style="color:blue return<span style="font-size:11px ; </td>
</tr>
<tr>
<td> } </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 } </td>
</tr>
<tr>
<td> <span style="color:blue this<span style="font-size:11px .AllPropertiesValid = <span style="color:blue true<span style="font-size:11px ; </td>
</tr>
<tr>
<td style="background-color:#f7f7f7 </td>
</tr>
<tr>
<td> } </td>
</tr>
</tbody>
</table>
So it returns TRUE foreach. Is there a way i can change this to only work FOR ALL
<br/>
<br/>
Thanks again for any help.<br/>
View the full article