| | |
validation problem
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
hi,
iam having an application in which i need to validate all the fileds present above a particular field when user clicks on any field present in a page.similar to this link
http://my.naukri.com/manager/createa...cp=5424&wExp=N
is this possible using validator callout extender.
can we use javascript to achieve this functionality.
if thru javascript it is possible,can any one send me the code.
waiting for u r replies
iam having an application in which i need to validate all the fileds present above a particular field when user clicks on any field present in a page.similar to this link
http://my.naukri.com/manager/createa...cp=5424&wExp=N
is this possible using validator callout extender.
can we use javascript to achieve this functionality.
if thru javascript it is possible,can any one send me the code.
waiting for u r replies
Hi,
I can provide you the logic, that I think will work.
You need to create an 2d array holding the id's and type of all the elements on form.
then onclick event of any element call the function with the index number of that element.
using for loop you can check if all the elements are validated before that index or not.
Hope this will help you.
I can provide you the logic, that I think will work.
You need to create an 2d array holding the id's and type of all the elements on form.
then onclick event of any element call the function with the index number of that element.
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
function clicked(ind)
using for loop you can check if all the elements are validated before that index or not.
Hope this will help you.
Vivek Rawat
Keep solving complexities.
Keep solving complexities.
>>>can we use javascript to achieve this functionality.
Yes thats usually client side validation but some of the text boxes will need to be validated on the server side such as checking for username availabality that can be done on the server
For user name u need to use the RangeValidator coz u need minimum range of 4 characters. RangeValdator have 3 properties to mention.. minimum, maximum and data type u can only do that on server side script validation.... the password needs CompareValidator which have 2 properties, FieldToCompare property and fieldToValidate property and maybe the ErrorMsg property which will tell the user that the passwords entered does not match and also that can be done on the server side script validation
let me take what I said about client side validation back coz as far as I know all those control on that form are rich server controls not html controls except for file field textbox and browse button to uplaod file, simple bcoz no rich server control support it so it is n will alwayz be html server control
this requires a lot of work and server connection and im quite sure ur not looking for that.... I think u need to tell ur Dani fellows what exactly u need to do cos the site u uploaded does not give any clear path to take on
Yes thats usually client side validation but some of the text boxes will need to be validated on the server side such as checking for username availabality that can be done on the server
For user name u need to use the RangeValidator coz u need minimum range of 4 characters. RangeValdator have 3 properties to mention.. minimum, maximum and data type u can only do that on server side script validation.... the password needs CompareValidator which have 2 properties, FieldToCompare property and fieldToValidate property and maybe the ErrorMsg property which will tell the user that the passwords entered does not match and also that can be done on the server side script validation
let me take what I said about client side validation back coz as far as I know all those control on that form are rich server controls not html controls except for file field textbox and browse button to uplaod file, simple bcoz no rich server control support it so it is n will alwayz be html server control
this requires a lot of work and server connection and im quite sure ur not looking for that.... I think u need to tell ur Dani fellows what exactly u need to do cos the site u uploaded does not give any clear path to take on
Last edited by Traicey; Jul 9th, 2008 at 6:26 am.
Some people get so rich they lose all respect for humanity. That's how rich I want to be.
hi,
basically iam a asp.net developer,i wan to ahcieve this functionality using javascript,this is the code i have used
in design side
in code
is there a better method to achieve this functionality
My other query is
is there a possibility to validate the fields above a particular field on onblur event
basically iam a asp.net developer,i wan to ahcieve this functionality using javascript,this is the code i have used
in design side
html Syntax (Toggle Plain Text)
<head runat="server"> <title>Untitled Page</title> <script> function validataform(ctrl) { if(ctrl.value=="") { var lbl=document.getElementById("lblerr"); lbl.style.visibility='visible'; ctrl.style.border="1px solid #ff0000"; var imgerror=document.getElementById("imgerror"); imgerror.style.display="block"; var imgarrow=document.getElementById("imdisp"); imgarrow.style.display="block"; var imgcorrect=document.getElementById("imgcorrect"); imgcorrect.style.display="none"; } else { var imgcorrect=document.getElementById("imgcorrect"); imgcorrect.style.display="block"; var lbl=document.getElementById("lblerr"); lbl.style.visibility='hidden'; ctrl.removeAttribute('style'); ctrl.parentNode.className =""; var imgerror=document.getElementById("imgerror"); imgerror.style.display="none"; var imgarrow=document.getElementById("imdisp"); imgarrow.style.display="none"; } } </script> </head> <body> <form id="form1" runat="server"> <div> <table> <tr> <td> <asp:Label ID="lblname" runat="server" Text="Name"></asp:Label> </td> <td> <table> <tr> <td> <asp:TextBox ID="txtname" runat="server" class=""></asp:TextBox></td> <td> <asp:Image ID="imgcorrect" runat="server" style="display:none" ImageUrl="~/EtgsImages/OnlineImgs/correct.gif" /><asp:Image ID="imgerror" runat="server" style="display:none" ImageUrl="~/EtgsImages/OnlineImgs/erroricon1.gif" /></td> </tr> </table> </td> </tr> <tr> <td> </td> <td> <table> <tr> <td> <asp:Image ID="imdisp" runat="server" style="display:none" ImageUrl="~/EtgsImages/OnlineImgs/error.gif" /></td> <td> <asp:Label ID="lblerr" runat="server" Font-Bold="false" ForeColor="red">Please enter username</asp:Label></td> </tr> </table> </td> </tr> <tr> <td colspan="2" align="center"> <asp:Button ID="btnsubmit" runat="server" Text="Submit" /> </td> </tr> </table> </div> </form> </body>
in code
JavaScript Syntax (Toggle Plain Text)
protected void Page_Load(object sender, EventArgs e) { txtname.Attributes.Add("onblur", "javascript:return validataform(this);"); if (!Page.IsPostBack) { lblerr.Style.Add("visibility", "hidden"); } }
My other query is
is there a possibility to validate the fields above a particular field on onblur event
Last edited by peter_budo; Jul 10th, 2008 at 9:45 am. Reason: Keep It Organized - please use [code] tags
Hi,
The code will look like this.
I think this will solve the problem.
The code will look like this.
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
<script language=javascript> var arrmsg = new Array(3); for(j=0;j<3;j++) { arrmsg[j]=""; } var arrelement = new Array(3); for(j=0;j<3;j++) { arrelement[j] = new Array(2); } arrelement[0][0] = txtfn; arrelement[0][1] = text; arrelement[0][0] = txtln; arrelement[0][1] = text; arrelement[0][0] = txtmn; arrelement[0][1] = text; </scirpt> <input type=text name=txtfn id=txtfn onclick=clicked(0)> <input type=text name=txtln id=txtln onclick=clicked(1)> <input type=text name=txtmn id=txtmn onclick=clicked(2)>
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
function clicked(ind) { var flag=false; for(i=0;i<ind;i++) { if(checkelement[i][1] == "text") { if(checkblank(arrelement[i][0]) { arrmsg[i] = arrelement[i][0]+" can not be blank"; flag=true; } } } } function checkblank(field) { if(document.getElementById("+field+").value == "") return false; else return true; }
I think this will solve the problem.
Vivek Rawat
Keep solving complexities.
Keep solving complexities.
i think this is the right code
JavaScript Syntax (Toggle Plain Text)
function clicked(ind) { var arrmsg = new Array(3); for(j=0;j<3;j++) { arrmsg[j]=""; } var arrelement = new Array(3); for(j=0;j<3;j++) { arrelement[j] = new Array(2); } arrelement[0][0] = 'txtfn'; arrelement[0][1] = 'text'; arrelement[1][0] = 'txtln'; arrelement[1][1] = 'text'; arrelement[2][0] = 'txtmn'; arrelement[2][1] = 'text'; var flag=false; for(i=0;i<=ind;i++) { if(arrelement[i][1] == "text") { if(checkblank(arrelement[i][0])) { arrmsg[i] = arrelement[i][0]+"can not be blank"; alert(arrmsg[i]); flag=true; } } } } function checkblank(field) { if(document.getElementById(field).value == "") return true; else return false; }
Last edited by peter_budo; Jul 11th, 2008 at 7:37 am. Reason: Keep It Organized - please use [code] tags
![]() |
Similar Threads
- .net validation/javascript conflict (ASP.NET)
- about:blank Trusted Start Page problem (Viruses, Spyware and other Nasties)
- Problem with validation in c (C++)
- Simple problem regardingform elements (ASP)
- Problem with comp & mouse very slow suddenly (Windows 95 / 98 / Me)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: Mail form Subject Help
- Next Thread: Urgent requirement of image gallery in php
| Thread Tools | Search this Thread |
Tag cloud for JavaScript / DHTML / AJAX
ajax ajaxcode ajaxhelp animate api automatically beta boarder box bug calendar card checkbox child class column cookies createrange() css cursor dependent disablefirebug dom download dropdown editor element engine error events explorer ext file firehose flash form forms game google gwt html htmlform ie8 iframe image() images internet java javascript jawascriptruntimeerror jquery jsf jsfile jump math matrixcaptcha microsoft mimic mp3 mysql object offline onmouseoutdivproblem onreadystatechange parent passing pdf php player post problem progressbar rated rating regex runtime scroll search select session shopping size sql star stars stretch text textarea twitter validation w3c web website window windowofwords windowsxp wysiwyg xml xspf \n





