Click here to Skip to main content
12,251,686 members (59,627 online)
Rate this:
 
Please Sign up or sign in to vote.
hi all,

i want to validate my html text box without runat="server" to requiredfieldvalidator.

thanks,
krunal
Posted 12-Sep-12 1:36am
kk20141.9K
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

It's not possible to validate a HTML control using RequiredFieldValidator. If you want to validate your HTML control client side only then you need to use JavaScript.

RequiredFieldValidator is used only for server controls.


--Amit
  Permalink  
Comments
kkakadiya 12-Sep-12 8:05am
   

hi, i have assigned my html control value to other text box which is runat="server". see below.

on .aspx page code is:
<input id="txtplace" type="text" visible="false" value="" runat="server" />
<script type="text/javascript">

function CopyVal() {
document.getElementById("txtplace").value = document.getElementById("input1").value;

return false;
}
function isValid(tab)
{
return Page_ClientValidate();
}
</script>

on code behind i am wirting code:

txtplace.Attributes.Add("onblur", "javascript:return isValid('txtplace');");

bt it doesnt work.now is there any solution?
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

Hi, you can validate your html text box with javascript:


<input name="tel" id="tel" type="text" size="20" maxlength="200" style="width: 200px;"  önblur="checkTelRequired(this);" /><label>*</label>
<label id="telRequired" style="display: none;">Required</label>
function checkRequired(whatYouTyped) {
     var txtTel = whatYouTyped.value;
     var telRequired = document.getElementById("telRequired");
     if (txtTel == "") {
         telRequired.style.display = "";
         return false;
     }
     else {
         telRequired.style.display = "none";
     }
     return true;
}
  Permalink  
v3
Comments
kkakadiya 12-Sep-12 8:15am
   
hi, in my project on form load there will be text "mandetory*" next to every label. on selection/input of text it will disappear.
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 5

hi,

i partially success. now the pro. is that when i click any where in webpage or select or input values t controls then my text disappears.

i want it disappear on selection on that dropdown control only.
  Permalink  
v3
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 6

CLIENT SIDE VALIDATION:
<label for="fname">First Name *</label>
 <input required type="text" name="fname" id="fname">
USE JQUERY/JAVASCRIPT FOR VALIDATIONS
RequiredFieldValidator IS FOR SERVER SIDE VALIDATIONS.
WITH OUT RUN@SERVER YOU CANNOT DO THAT
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160426.1 | Last Updated 27 May 2014
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100