validation file
Moderator: General Moderators
validation file
hi all
i need to make file to valid the input text
e.g:-
when i enter on the textfield for name we must enter char from (a-z) other wise error
???
how
i need to make file to valid the input text
e.g:-
when i enter on the textfield for name we must enter char from (a-z) other wise error
???
how
- aceconcepts
- DevNet Resident
- Posts: 1424
- Joined: Mon Feb 06, 2006 11:26 am
- Location: London
Re: validation file
Code: Select all
preg_match("/[A-Za-z]*/", $string);Re: validation file
ok
but u canoot tell me where i put it
my code is
where i put your code
but u canoot tell me where i put it
my code is
Code: Select all
label>
<input type="text" name="Time" />
</label>
- aceconcepts
- DevNet Resident
- Posts: 1424
- Joined: Mon Feb 06, 2006 11:26 am
- Location: London
Re: validation file
Basically the line of code I posted compares a given string with the pattern "/[A-Za-z]*/"
This code should go in your validation section of code - once the form has been submitted.
Have you created a form?
This code should go in your validation section of code - once the form has been submitted.
Have you created a form?
Re: validation file
this file i wont to valid it
Code: Select all
<input type="text" name="FirstName" />- aceconcepts
- DevNet Resident
- Posts: 1424
- Joined: Mon Feb 06, 2006 11:26 am
- Location: London
Re: validation file
I know you want to validate an input field's value.
What you need to do is create a form:
A form is needed to post/submit the form fields.
What you need to do is create a form:
Code: Select all
<form method="post">
<input type="text" name="FirstName" />
<input type="submit" name="submit" value="submit" />
</form>
Re: validation file
ok
this is the form
but where the valid of text
this is the form
but where the valid of text
- aceconcepts
- DevNet Resident
- Posts: 1424
- Joined: Mon Feb 06, 2006 11:26 am
- Location: London
Re: validation file
You need to determine whether the form has been submitted:
Code: Select all
if(isset($_POST['submit']))
{
//preg_match("/[A-Za-z]*/", $_POST['FirstName']); goes here
}
Re: validation file
???
i canot understand
i canot understand
- aceconcepts
- DevNet Resident
- Posts: 1424
- Joined: Mon Feb 06, 2006 11:26 am
- Location: London
Re: validation file
People don't usually just spew out the code - try learning more about basic html and logic.
Anyway, here is one rather crude way of doing what you want:
Anyway, here is one rather crude way of doing what you want:
Code: Select all
<?
if(isset($_POST['submit']))
{
if(!empty($_POST['FirstName']))
{
if(!preg_match("/[A-Za-z]*/", $_POST['FirstName']))
{
//error
}
}
}
?>
<form method="post">
<input type="text" name="FirstName" />
<input type="submit" name="submit" value="submit" />
</form>