can we use javascript and ajax on same control in

Posted by Shanky11 under ASP.NET AJAX on 2/14/2013 | Points: 10 | Views : 1160 | Status : [Member] | Replies : 1
can we use javascript and ajax on same control?????????????????
i have a form inside that 4 txtfield are there i used required field validator and ajax validator extender
but this is only for user cant move ahead unless and until he fill all the details
now the problem is that if user enter the number in name field and character in mobile no filed how can i validate that
if i m using jvascript then ajax is not wrking
how an i coe across this problem

Please provide solution for this not web link


Posted by: lakhansin-22735 on: 7/8/2013 [Member] Starter | Points: 25


I'm not very clear about your problem, but as per my understanding you can use CustomValidator, using this validator control you can achieve both JavaScript and Ajax functionality.
see the below code at ASPX page
<asp:TextBox ID="txtLicenseNo" runat="server" MaxLength="20" Font-Bold="true"></asp:TextBox><br />

<asp:RequiredFieldValidator ID="rfvLicenseNo" runat="server" ControlToValidate="txtLicenseNo"
ErrorMessage="Required" Display="Dynamic" SetFocusOnError="true" ValidationGroup="vgLicense"
<asp:CustomValidator ID="cmvalLicneseNumber" SetFocusOnError="true" ValidationGroup="vgLicense"
ControlToValidate="txtLicenseNo" ClientValidationFunction="ValLicenseLength"
Display="Static" runat="server" ErrorMessage="Invalid"></asp:CustomValidator>

function ValLicenseLength(sender, e) {
var LicenseLength = (document.getElementById('<%=txtLicenseNo.ClientID %>').value).length;
e.IsValid = true;
if (LicenseLength < 4) {
e.IsValid = false;
else {
e.IsValid = true;

Please, let me know something more, so that I will help you.


Lakhan Singh
Tech Lead
BeyondKey System Pvt. Ltd.
Indore, M.P.

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response