Hii Experts,
im facing a problem with the javascript validation.i've a gridview in my web form and added a footer tempalte and placed textboxes in tht tempalte ,just to add a new row to the gridview and i wanna to validate the emalid entered in the footertextbox of the gridview. so i added a javasript function : -
function OnCheckEmailID(srcID)
-
{
-
-
var email=document.getElementById(srcID);
-
var filter =/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
-
if (!filter.test(email.value)&& !email.value=="")
-
{
-
alert('Please provide a valid email address');
-
email.value="";
-
email.focus();
-
return false;
-
}
-
else
-
return true;
-
-
}
and i linked this function to the change event of my text box in the source code like this: -
<asp:TextBox ID="txtdummy" runat="server" Width="150px" OnChange="OnCheckEmailID('ctl00_BodyContent_txtdummy')" ></asp:TextBox>
But unfortunately this is not working ...but for testing purpose i placed one textbox outside the gridview and i linked the javascript function to the textchange event in the same ..thn its working fine...
so the function is getting called for the textboxes outside the gridview..but not for the textboxes in the footer template of the gridview.
can anybody tell me what im missing ..
Thanks in Advance..
Rgds,
BTR.
12 9896
can anybody help me in finding the solution for this.
Thanks
Rgds,
BTR.
Isn't onchange the html input event through which to call JS events. Easiest way to get OnCheckEmailID working is therefore to change textbox to html input. Otherwise use server side code.
Thanks for your reply. everytime you are only replying to my queries .Thanks for your time.
Its working now.
But may i know the reason why its behaving like this..coz its working for other textboxes which are outside of the gridview.
And when i try to call the JS function for the OnTextChanged instead of OnChange event of the server side Textbox i.e. <asp:Textbox> ,i got the runtime error..".too many characters in the literal".
Requesting you kindly explain me whts going on behind the scenes.
Rgds,
BTR.
Frinavale 9,735
Recognized Expert Moderator Expert
I'm not sure what's causing the problem but have you considered using a RegularExpressi onValidator instead?
Add one to your footer template and see if it works...
Dear kenobewan,
If you dont mind can you please tell me how can i do this validation on server side,instead of client side.like when i click on the Insert button which is there in the Footertemplate of the gridview it has to validate the footer textbox control's text and alert the user if he enters no value otherwise proceed for the insertion operation.
As you know we dont have MessageBox facility in ASP.NET.
Please Help me .
Rgds,
BTR.
Hii,
I found that the ClientID( i.e.in the HTML source) of the textboxes which are there in the footer template of the Gridview is changing ,its not constant .and also its looks to be diffrent
'ctl00_BodyCont ent_editgrid_ct l64_tbmail' this is the ID of a textbox with id=tbmail which is thr in the footertemplate;
and for others the id is "ctl00_BodyCont ent_dvMeetingDe tail_txtorganiz ername"
if we compare the both the diffrece is ,ct164 is added which is not constant and keep on changing.some times its 160 and sometimes its 162 and today its 164.
Is this is the reason why its not geting the reference of the textbox controls which are placed in the footer row of a gridview.
Kindly help me..
Rgds,
BTR.
Frinavale 9,735
Recognized Expert Moderator Expert
Change your JavaScript to accept a TextBox as the parameter.
So your function wouldn't change much....just pass it the TextBox element instead of the ID of the TextBox element: -
function OnCheckEmailID(src)
-
{
-
-
var email=src;
-
var filter =/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
-
if (!filter.test(email.value)&& !email.value=="")
-
{
-
alert('Please provide a valid email address');
-
email.value="";
-
email.focus();
-
return false;
-
}
-
else
-
return true;
-
-
}
You would pass the function the TextBox like so: - <tdummy" runat="server" Width="150px" OnChange="OnCheckEmailID('this')" ></asp:TextBox>
This would get around the problem with the changing ClientID.
Dear Frinavale,
Thanks for the reply.
I changed the javascript function as you said ..but unfortunately its also not wroking.
and when i try to debug the javascript function in Visual studio 2005,wht i found is tht its not getting the footer textbox reference...but getting null value and its breaking immediatly..
I passes the name of the textbox as a parameter to the javascript function and chnged the function accrodingly ..thn also the same problem.
Really getting irritated with this strange behaviour..god knows wht's the problem is.
Rgds,
BTR.
Dear kenobewan and Frinavale,
You both please help me...im in the middle of the ocean.
Rgds,
BTR.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Lee Moore |
last post by:
I have the following code, which I thought should work. I get an error
stating ...
Could not find control 'GOAL_TEXT_CONTROL' in ControlParameter 'GOAL_TEXT'.
Any help would be great.
<-------------------------- Code Snippet --------------------------->
<asp:GridView ID="GridView1" Runat="server"
|
by: Robert Smith jr. |
last post by:
Hello,
Please pardon my newbie question ...
I am building an ASP.NET page that displays a recordset with a Delete
statement enabled (this all works fine). I want to Insert the current
row *that is going to be deleted* into another table, before the
original data is deleted.
I am trying to use the RowDeleting method to call an Update or Insert
|
by: =?Utf-8?B?cGF0cmlja2RyZA==?= |
last post by:
Hi all!
I have a gridview inside a datagrid (nested) for which (gridview) the
rowcommand is not raised in order to delete a row from the grid!
I also tried OnRowCommand="method", didn't work either!
Does anyone know how can I make this work?
Thanks in advance!
|
by: KeesH |
last post by:
Hi,
I am quite desperate now because I made a nice webshop with a gridview where the customer is able to update the amount of products (Hostas in my situation) or delete the row.
The problem is that every works really fine with this code when customers order approximatelly a maximum of 35 products.
What I learned so far is to set the EnableViewState="False" for all the labels that don't need a viewstate. This helped a lot.
What can I do...
|
by: seanmatthewwalsh |
last post by:
This should be REALLY straightforward. I have a gridview that allows
editing, deleting and inserting (from the footer row). There is a Drop
Down ListBox in the one column, which needs to ALWAYS set to a default
value (but not always the same value, so I can't set it declaritively.
It will ultimately depend on a session variable as to which default to
use).
However, the point is that the DDL in the footer (insert) row must
ALWAYS be set,...
| |
by: Andy B |
last post by:
I have a GridView with a LINQDataSource attached to it. My code in the aspx
markup is below. I need to know why only the checkbox field for the
activated column is getting updated (the EditTemplate). None of the other
columns get updated except for that one. Any ideas? The only column that is
not able to be updated is the ID column, but that isn't even in the table.
<asp:GridView ID="EternityNewsMemberList" runat="server"...
|
by: Ahmedhussain |
last post by:
Hi there,
I m doing work on a gridview and Im getting an error:
A potentially dangerous Request.Form value was detected from the client (ctl00$Content$GridView1$ctl03$TextBox1="<span class='txtColo...")
Im using an access database. and when ever I try to update this it doesnt work.
<%@ Page Language="C#" MasterPageFile="Mysite.master" Title="Untitled Page" %>
<script runat = "server">
protected void Page_Load(object sender,...
|
by: parshupooja |
last post by:
Hey All,
I have where I want to do some manipulations and show in other column but unable to find their values in RowDatabound event even though I have two records in gridview
<asp:GridView ID="GridView1" runat="server" ShowFooter="True" AutoGenerateColumns="false" Width="700px">
<Columns>
<asp:TemplateField HeaderText="Qty">
<EditItemTemplate>
<asp:TextBox...
|
by: janetb |
last post by:
I have a gridview with an update capabilities - a textbox column (roomName), a dropdownlist(orgID), a dropdownlist(roomTypeID),a checkbox column (dialOut), a checkbox column (dialIn). When I try to add another checkbox column, the sql database isn't updated properly with a 0/1 or false/true but with null. I've tried everything I can think of. Can anyone help?
Data command stuff:
UpdateCommand="update telehealth.dbo.xTblRoom...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |