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..

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

commented: I am developing project management System +0
Member Avatar for diafol

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

$rawnum = '(09287) 34648';
$num = preg_replace('/\D/','',$rawnum);
echo (strlen($num) === 10) ? 'valid' : 'invalid';
commented: 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..

Member Avatar for diafol

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??

Thanks Diafol

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.