phorcon3 Posted October 6, 2009 Share Posted October 6, 2009 i need this one function which should be written in php and javascript php: $text = $_POST['text']; javascript: var text = document.getElementById('text').value; so, "text": 1) may contain a-zA-Z0-9 as well as a period "." 2) first letter must be alphanumeric, so ".text" would result in an error 3) there should be no consecutive periods allowed, so "text..text" would result in an error 4) last letter must be alphanumeric as well, so "text." would also result in an error does anyone know how to do this with just on line of code (regex) in both, php and javascript? thanks in advance Link to comment https://forums.phpfreaks.com/topic/176713-solved-php-javascript/ Share on other sites More sharing options...
cags Posted October 6, 2009 Share Posted October 6, 2009 This should cover 1, 2 and 4. Probably not the best approach, I'm some somebody will do better but it's a start. I have no idea how you'd check that there are no double fullstops. "~^[a-zA-Z][a-zA-Z0-9\.]+?[a-zA-Z]$~" Link to comment https://forums.phpfreaks.com/topic/176713-solved-php-javascript/#findComment-931676 Share on other sites More sharing options...
phorcon3 Posted October 6, 2009 Author Share Posted October 6, 2009 i got it. thanks anyways. Link to comment https://forums.phpfreaks.com/topic/176713-solved-php-javascript/#findComment-931933 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.