Validation of Java Scipt

Posted by Mahesh_Chs under JavaScript on 3/26/2012 | Points: 10 | Views : 3395 | Status : [Member] | Replies : 9
Can you please tell me how to validate the field by using java script, like if i want to enter Only Letters or Only digits , and length of the string should be in between 6 and 8 characters and email validations.




Responses

Posted by: Self-Innovator on: 3/26/2012 [Member] Bronze | Points: 25

Up
0
Down
Fhi refer this link for Emasil validation...
http://www.dotnetfunda.com/codes/code1859-email-validation-using-javascript.aspx
To validat only Numbers

function EnterOnlyNumbers(x)

{
var len=x.value.length;
var s_charcode=0;
for(var s_i=0;s_i<len;s_i++)
{
s_charcode=x.value.charCodeAt(s_i);
if(!((s_charcode>=48 && s_charcode<=57)))
{
alert("Enter only numbers");
x.value="";
x.focus();
return false;
}
}
return true;
}
<asp:textbox id="txt1" ruat="server" onChange="EnterOnlyNumbers(this)">


Join Hands Change lives
Thanks & Regards
Straight Edge Society

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

Posted by: Sksamantaray on: 3/26/2012 [Member] Silver | Points: 25

Up
0
Down
Hi ,
Try this for only numbers:
http://www.cambiaresearch.com/articles/39/how-can-i-use-javascript-to-allow-only-numbers-to-be-entered-in-a-textbox

Thanks,
Sanjay

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

Posted by: Sksamantaray on: 3/26/2012 [Member] Silver | Points: 25

Up
0
Down
Hi,
For only Text:
http://sourcefirst.wordpress.com/2007/12/10/javascript-text-only-input/

Try green highlited section from here:
http://forums.asp.net/t/1420621.aspx/1

Thanks,
Sanjay

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

Posted by: Sksamantaray on: 3/26/2012 [Member] Silver | Points: 25

Up
0
Down
Hi,
For Email Validation refer to these :
http://www.smartwebby.com/DHTML/email_validation.asp
http://www.javascriptkit.com/script/script2/acheck.shtml

Thanks,
Sanjay

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

Posted by: Patel28rajendra on: 3/26/2012 [Member] Starter | Points: 25

Up
0
Down
Hi

for Email validation you can refer this link

http://www.w3schools.com/js/js_form_validation.asp

R D Patel

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

Posted by: Patel28rajendra on: 3/26/2012 [Member] Starter | Points: 25

Up
0
Down
Hi

another nice link for email validation

http://www.white-hat-web-design.co.uk/blog/javascript-validation/

R D Patel

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

Posted by: Patel28rajendra on: 3/26/2012 [Member] Starter | Points: 25

Up
0
Down
Hi

for numbers and letter see this link

http://www.w3resource.com/javascript/form/letters-numbers-field.php

R D Patel

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

Posted by: Patel28rajendra on: 3/26/2012 [Member] Starter | Points: 25

Up
0
Down
Hi

for almost all type of validation refer this one

http://webcheatsheet.com/javascript/form_validation.php

R D Patel

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

Posted by: Patel28rajendra on: 3/26/2012 [Member] Starter | Points: 25

Up
0
Down
Hi

Please Mark as answer if it helps

R D Patel

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

Login to post response