Jump to content

[SOLVED] eregi form problem


Kemik

Recommended Posts

Hello all,

 

Can anyone explain why my form won't allow "Test Title" without the " to pass through? I originally thought it was the space, but it doesn't allow "TestTitle" either.

 

<?php 
/* Ensure title is alphanumeric */
         else if(!eregi("^([0-9a-z]\.\' \-)+$", $subtitle)){
            $form->setError($field, "* Title not alphanumeric");
         } ?>

 

The above code is part of a range of checks, however as the form is giving me this error I can only presume it's because of this area of code.

 

Edit: I taken the part of code from a username check (the code above is to check the title of a news post). You can see the original code below...

<?php
         /* Check if username is not alphanumeric */
         else if(!eregi("^([0-9a-z])+$", $subuser)){
            $form->setError($field, "* Username not alphanumeric");
         } ?>

Link to comment
https://forums.phpfreaks.com/topic/60807-solved-eregi-form-problem/
Share on other sites

I've tried adding A-Z however it still doesn't work.

 

<?php

/* Ensure title is alphanumeric */
         else if(!eregi("^([0-9a-zA-Z\.\' \-]\.\' )+$", $subtitle)){
            $form->setError($field, "* Title not alphanumeric");
         }

?>

 

EDIT: I removed \.\'  after the ] and it now works... I think.

 

Thanks.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.