JavaScript - Name Validation
Asked By Sathish N
08-Oct-08 05:23 AM
Hi!
I want to enter the field for the following structure (ex:St.Ann's Hr.Sec School) in textbox in ASP.Net 2005 using JavaScript Validation.Can any one provide samples.
Thanks
validating txtbox containg only characters
use this below javascript code for validating txtbox containg only characters......
function ValidateText()
{
var txtVal = document.Form1.Elements["textboxname"].value;
var len = txtVal.length;
for(var i = 0;i<len; i++)
{
if(txtVal.charAt(j) < 'A' || txtVal.charAt(j) > 'Z' && txtVal.charAt(j) <'a' || txtVal.charAt(j)>'z')
{
alert("Invalit Text")
return false;
}
}
hope this will work nway have nice day........
}
verified output
You behind code language as C# and use below function. I have verified the output.
static void validname(string[] args)
{
Regex regex = new Regex(@"^[a-z A-Z .]*$");
string input = null;
Console.Write("Enter input: ");
input =
Console.ReadLine();
if (input == null || regex.Match(input).Success == false)
{
Console.WriteLine("Invalid input. Try again.");
Console.Write("Enter input: ");
return false
}
return true;
Console.WriteLine("Validated!");
Console.Read();
}
check this for name validation

<!-- TWO STEPS TO INSTALL VALIDATION:
1. Copy the coding into the HEAD of your HTML document
2. Add the last code into the BODY of your HTML document -->
<!-- STEP ONE: Paste this code into the HEAD of your HTML document -->
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Begin
function checkFields() {
missinginfo = "";
if (document.form.name.value == "") {
missinginfo += "\n - Name";
}
if ((document.form.from.value == "") ||
(document.form.from.value.indexOf('@') == -1) ||
(document.form.from.value.indexOf('.') == -1)) {
missinginfo += "\n - Email address";
}
if ((document.form.website.value == "") ||
(document.form.website.value.indexOf("http://") == -1) ||
(document.form.website.value.indexOf(".") == -1)) {
missinginfo += "\n - Web site";
}
if(document.form.comments.value == "") {
missinginfo += "\n - Comments";
}
if (missinginfo != "") {
missinginfo ="_____________________________\n" +
"You failed to correctly fill in your:\n" +
missinginfo + "\n_____________________________" +
"\nPlease re-enter and submit again!";
alert(missinginfo);
return false;
}
else return true;
}
// End -->
</script>
</HEAD>
<!-- STEP TWO: Copy this code into the BODY of your HTML document -->
<BODY>
<form name=form onSubmit="return checkFields();">
<input type=hidden name=to value='you @ your domain . web'>
<input type=hidden name=subject value="Freedback">
<pre>
Name: <input type=text name="name" size=30>
E-mail: <input type=text name="from" size=30>
Web Site: <input type=text value="http://" name="website" size=30>
Comments:
<textarea rows=3 cols=40 name="comments"></textarea>
<input type=submit name="submit" value="Submit Form!">
</pre>
</form>
<p><center>
<font face="arial, helvetica" size="-2">Free JavaScripts provided<br>
by <a href="http://javascriptsource.com">The JavaScript Source</a></font>
</center><p>
or
check this out
http://www.w3schools.com/js/js_form_validation.asp
zXX replied to C_A P
zXX replied to C_A P
select distinct DataBase I want to add: SELECT DISTINCT [RIVER SCHOOL].email1 FROM [RIVER SCHOOL]; to the following query in an accrees database but I just can't seem to IsNull([dad]), [mom], IIf([dad]> = "A" And [mom]> = "A", [dad] & " " & "and" & " " & [mom]))) AS ggwname, [River School].Sent, [River School].Dad, [River School].Mom, [River School].Student, [River School].Last, [River School].grade, [River School].Address, [River School].Phone1, [River School].Phone2, [River School].email1, [River School
the database but now I am stuck (again!) Here is what I have table 1- School School name, school number, school address, phone, etc. . . . table 2- Fiscal Report fiscal year, quarter number, school number (look up from other table) revenues, expenses, etc. . . . Now I need to generate a report that shows the "Missing" School that have not turned in their reports for a specific quarter. I have built a help! I have a June 1st deadline! Thanks Try This Query : SELECT S1.SchoolName From School S1, Shool S2, FiscalReport WHERE (S1.SchoolNumber = FisacalReport.SchoolNumber) AND (S2.SchoolNumber = FisacalReport.SchoolNumber) AND a error. Is that where this is supposed to go? Thanks SELECT S1.SchoolName From School S1, Shool S2, FiscalReport WHERE (S1.SchoolNumber = FisacalReport.SchoolNumber) AND (S2.SchoolNumber = FisacalReport.SchoolNumber) AND
the user to. The stored procedure then parses the ; delimited list and enters a userid-school record for each school into the tbl_UsersInSchools table . I was wondering how I could make the while statement at CREATE PROCEDURE dbo.wsp_Roles_AssignSchoolsByUserId @UserId uniqueidentifier, @Schools varchar(8000) AS - - declare a table to hold school names DECLARE @USER_SCHOOLS TABLE ( ID INT IDENTITY (1, 1), SCHOOL char(4) ) - - parse the delimited list of schools into individual schools - - and insert the school names into the user_schools table INSERT INTO @USER_SCHOOLS SELECT VALUE AS SCHOOL FROM dbo.fn_Split( @Schools, ';') - - check to see if table has any records DECLARE @COUNT int SELECT @COUNT = count(*) FROM @USER_SCHOOLS IF @COUNT > 0 BEGIN - - select individual school names and insert them along with the user id - - into tbl_UsersInSchools DECLARE @SCHOOL char(4) WHILE( @COUNT > 0 ) BEGIN SET @SCHOOL = (SELECT TOP 1 SCHOOL from @USER_SCHOOLS) INSERT