я хочу проверить номер телефона. Макс. 10 номеров.
это моя кодировка php файла
<div id="sign_up">
<h4><?php
if($_REQUEST['page']=='login' && $_REQUEST['page1']=='sign_up')
{
_e(REGISTRATION_NOW_TEXT);
}else
{
_e(REGISTRATION_NOW_TEXT);
}
?></h4>
<?php
if ( $_REQUEST['emsg']==1)
{
echo "<p class=\"error_msg_fix\"> ".EMAIL_USERNAME_EXIST_MSG." </p>";
}
?>
<div class="login_content">
<?php echo stripslashes(get_option('ptthemes_reg_page_content'));?>
</div>
<div class="registration_form_box">
<form name="registerform" id="registerform" action="<?php echo get_option( 'siteurl' ).'/?page=login&action=register'; ?>" method="post">
<input type="hidden" name="reg_redirect_link" value="<?php echo $_SERVER['HTTP_REFERER'];?>" />
<p class="note"><span class="indicates">*</span> <?php _e(INDICATES_MANDATORY_FIELDS_TEXT);?></p>
<h5 class="rfh"><?php _e(PERSONAL_INFO_TEXT);?> </h5>
<div class="form_row clearfix">
<label><?php _e(EMAIL_TEXT) ?><span class="indicates">*</span></label>
<input type="text" name="user_email" id="user_email" class="textfield" value="<?php echo esc_attr(stripslashes($user_email)); ?>" size="25" />
<div id="reg_passmail">
<?php _e(REGISTRATION_MESSAGE) ?>
</div>
<span id="user_emailInfo"></span>
</div>
<div class="row_spacer_registration clearfix" >
<div class="form_row clearfix">
<label>
<?php _e(FIRST_NAME_TEXT) ?>
<span class="indicates">*</span></label>
<input type="text" name="user_fname" id="user_fname" class="textfield" value="<?php echo esc_attr(stripslashes($user_fname)); ?>" size="25" />
<span id="user_fnameInfo"></span>
</div>
<div class="form_row clearfix">
<label>
<?php _e(LAST_NAME_TEXT) ?>
</label>
<input type="text" name="user_lname" id="user_lname" class="textfield" value="<?php echo esc_attr(stripslashes($user_lname)); ?>" size="25" />
</div>
</div>
<div class="row_spacer_registration clearfix" >
<h5 ><?php _e(ADD_INFO_TEXT);?> </h5>
<div class="form_row clearfix">
<label>
<?php _e(ADDRESS1_TEXT) ?>
</label>
<input type="text" name="user_add1" id="user_add1" class="textfield" value="<?php echo esc_attr(stripslashes($user_add1)); ?>" size="25" />
</div>
<div class="form_row clearfix">
<label>
<?php _e(ADDRESS2_TEXT) ?>
</label>
<input type="text" name="user_add2" id="user_add2" class="textfield" value="<?php echo esc_attr(stripslashes($user_add2)); ?>" size="25" />
</div>
</div>
<div class="row_spacer_registration clearfix" >
<div class="form_row clearfix">
<label>
<?php _e(CITY_TEXT) ?>
</label>
<input type="text" name="user_city" id="user_city" class="textfield" value="<?php echo esc_attr(stripslashes($user_city)); ?>" size="25" />
</div>
<div class="form_row clearfix">
<label>
<?php _e(STATE_TEXT) ?>
</label>
<input type="text" name="user_state" id="user_state" class="textfield" value="<?php echo esc_attr(stripslashes($user_state)); ?>" size="25" />
</div>
</div>
<div class="row_spacer_registration clearfix" >
<div class="form_row clearfix">
<label>
<?php _e(COUNTRY_TEXT) ?>
</label>
<input type="text" name="user_country" id="user_country" class="textfield" value="<?php echo esc_attr(stripslashes($user_country)); ?>" size="25" />
</div>
<div class="form_row clearfix">
<label>
<?php _e(POSTAL_CODE_TEXT) ?>
</label>
<input type="text" name="user_postalcode" id="user_postalcode" class="textfield" value="<?php echo esc_attr(stripslashes($user_postalcode)); ?>" size="25" />
</div>
</div>
<?php do_action('register_form'); ?>
<div class="fix"></div>
<h5><?php _e(OTHER_INFO_TEXT) ?></h5>
<div class="form_row clearfix">
<label>
<?php _e(YR_WEBSITE_TEXT) ?>
</label>
<input type="text" name="user_web" id="user_web" class="textfield" value="<?php echo esc_attr(stripslashes($user_web)); ?>" size="25" />
</div>
<div class="form_row clearfix">
<label>
<?php _e(PHONE_NUMBER_TEXT) ?>
</label>
<input type="text" name="user_phone" id="user_phone" class="textfield" value="<?php echo esc_attr(stripslashes($user_phone)); ?>" size="25" />
</div>
<div class="form_row clearfix">
<label>
<?php _e(TWITTER_TEXT) ?>
</label>
<input type="text" name="user_twitter" id="user_twitter" class="textfield" value="<?php echo esc_attr(stripslashes($user_twitter)); ?>" size="25" />
</div>
<!-- <a href="javascript:void(0);" onclick="return chk_form_reg();" class="highlight_button fr " >Register Now </a>-->
<input type="submit" name="registernow" value="<?php _e(REGISTER_NOW_TEXT);?>" class="btn_input_highlight btn_spacer" />
это мой код файла .js
$(document).ready(function(){
////////////LOGIN FORM START
//global vars
var loginform = $("#loginform");
var user_login = $("#user_login");
var user_loginInfo = $("#user_loginInfo");
var user_pass = $("#user_pass");
var user_passInfo = $("#user_passInfo");
//On blur
user_login.blur(validate_user_login);
user_pass.blur(validate_user_pass);
//On key press
user_login.keyup(validate_user_login);
user_pass.keyup(validate_user_pass);
//On Submitting
loginform.submit(function(){
if(validate_user_login() & validate_user_pass())
return true
else
return false;
});
////////////LOGIN FORM END
////////////REGISTRATION FORM START
var registerform = $("#registerform");
var user_login1reg = $("#user_login1reg");
var user_login1regInfo = $("#user_login1regInfo");
var user_email = $("#user_email");
var user_emailInfo = $("#user_emailInfo");
var user_fname = $("#user_fname");
var user_fnameInfo = $("#user_fnameInfo");
//On blur
user_login1reg.blur(validate_user_login1reg);
user_email.blur(validate_user_email);
user_fname.blur(validate_user_fname);
//On key press
user_login1reg.keyup(validate_user_login1reg);
user_email.keyup(validate_user_email);
user_fname.keyup(validate_user_fname);
//On Submitting
registerform.submit(function(){
if(validate_user_login1reg() & validate_user_email() & validate_user_fname())
return true
else
return false;
});
////////////REGISTRATION FORM END
//validation functions
function validate_user_login()
{
var input=$("#your-name").val();
var check=0;
if(input==''){
check=1;
}
if(input.indexOf("0") != -1){
check=1;
}
if(input.indexOf("1") != -1){
check=1;
}
if(input.indexOf("2") != -1){
check=1;
}
if(input.indexOf("3") != -1){
check=1;
}
if(input.indexOf("4") != -1){
check=1;
}
if(input.indexOf("5") != -1){
check=1;
}
if(input.indexOf("6") != -1){
check=1;
}
if(input.indexOf("7") != -1){
check=1;
}
if(input.indexOf("8") != -1){
check=1;
}
if(input.indexOf("9") != -1){
check=1;
}
if(check==1){
user_login.addClass("error");
user_loginInfo.text("Please Enter Username");
user_loginInfo.addClass("message_error2");
return false;
}
else{
user_login.removeClass("error");
user_loginInfo.text("");
user_loginInfo.removeClass("message_error2");
return true;
}
}
function validate_user_pass()
{
if($("#user_pass").val() == '')
{
user_pass.addClass("error");
user_passInfo.text("Please Enter Password");
user_passInfo.addClass("message_error2");
return false;
}
else{
user_pass.removeClass("error");
user_passInfo.text("");
user_passInfo.removeClass("message_error2");
return true;
}
}
function validate_user_login1reg()
{
if($("#user_login1reg").val() == '')
{
user_login1reg.addClass("error");
user_login1regInfo.text("Please Enter Username");
user_login1regInfo.addClass("message_error2");
return false;
}
else{
user_login1reg.removeClass("error");
user_login1regInfo.text("");
user_login1regInfo.removeClass("message_error2");
return true;
}
}
function validate_user_fname()
{
var input=$("#your-name").val();
var check=0;
if(input==''){
check=1;
}
if(input.indexOf("0") != -1){
check=1;
}
if(input.indexOf("1") != -1){
check=1;
}
if(input.indexOf("2") != -1){
check=1;
}
if(input.indexOf("3") != -1){
check=1;
}
if(input.indexOf("4") != -1){
check=1;
}
if(input.indexOf("5") != -1){
check=1;
}
if(input.indexOf("6") != -1){
check=1;
}
if(input.indexOf("7") != -1){
check=1;
}
if(input.indexOf("8") != -1){
check=1;
}
if(input.indexOf("9") != -1){
check=1;
}
if(check==1){
user_fname.addClass("error");
user_fnameInfo.text("Please Enter First Name");
user_fnameInfo.addClass("message_error2");
return false;
}
else{
user_fname.removeClass("error");
user_fnameInfo.text("");
user_fnameInfo.removeClass("message_error2");
return true;
}
}
// phone validate
//function validate_user_phone()
//{
var regEx = new RegExp("/[0-9]/");
$("#user_phone").bind("submit", function() {
if ($("#user_phone").val().length != 10 && !$("#user_phone").val().match(regEx)) {
$("#user_phone").show();
$.fancybox.resize();
return false;
}
});
//}
function validate_user_email()
{
var isvalidemailflag = 0;
if($("#user_email").val() == '')
{
isvalidemailflag = 1;
}else
if($("#user_email").val() != '')
{
var a = $("#user_email").val();
var filter = /^[a-zA-Z0-9]+[a-zA-Z0-9_.-]+[a-zA-Z0-9_-]+@[a-zA-Z0-9]+[a-zA-Z0-9.-]+[a-zA-Z0-9]+.[a-z]{2,4}$/;
//if it's valid email
if(filter.test(a)){
isvalidemailflag = 0;
}else{
isvalidemailflag = 1;
}
}
if(isvalidemailflag)
{
user_email.addClass("error");
user_emailInfo.text("Please Enter valid E-mail");
user_emailInfo.addClass("message_error2");
return false;
}else
{
user_email.removeClass("error");
user_emailInfo.text("");
user_emailInfo.removeClass("message_error");
return true;
}
}
});