0

Hi,

I would know how can I validate the following php form fields Need for my student project.
Please help me

Fields requied are

Mobile Number: (10 digits number field)
Gender **:(Radio button or drop down box)
**Email **: (valid email field)
**Date of Birth:
( YYYY/MM/DD)

Please help me..Urgent..

Thanks much in advance..

4
Contributors
6
Replies
12
Views
5 Years
Discussion Span
Last Post by heavyman
0

what work have you already done in your student project?
All of these can be done, have you look over PHP.net?

Votes + Comments
I am developing project management System
0

Try some of the preg_* functions, e.g.

$rawnum = '(09287) 34648';
$num = preg_replace('/\D/','',$rawnum);
echo (strlen($num) === 10) ? 'valid' : 'invalid';
Votes + Comments
Thanks for your reply..
0

Thanks Diafol and Squidge for your reply..

If I have any Javascript or JQuery codings, that would be more better than using PHP..

0

JS validation is a good first line of defence, but cannot be depended upon to prevent tainted data from reaching the server. You MUST use server-side validation/sanitizing.

If you want js validation - why post to the php forum?

This may work (jQuery):

    var rawnum = $('#mobile').val();
    var num = rawnum.replace(/\D/g, "");
    var response = (num.length == 10) ? 'valid' : 'invalid';
    alert(response + ": " + num);

Wonder who gave the -1 for my last post? Was it that bad??

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.