Doubt in javascript validation

hi friends i am having the javascript function where i am making a validation for the an username like below
<script type=“text/javascript”>
$(function() {
$(“.submnick”).click(function()
{
var nick= $(“#nick”).val();
var dataString1 = ‘nick=’ + nick;
var hello=nick.length;
var jump =‘[1]*$’;
if(hello<=3)
{
$(‘.successan’).fadeOut(200).hide();
$(‘.erroran’).fadeOut(200).show();
}
else if(nick==!nick.match(jump))
{

                				$('.successan').fadeOut(200).hide();
           	    				$('.erroran').fadeOut(200).show();
								//}
                			}
                			else
							{
                				$.ajax({
                						type: "POST",
            							url: "joinnick.php",
            							data: dataString1,
            							success: function()
										  {

												
												$('#slick-').hide();
												$('#slick-').show();
												


        								  }
            						   });
                			}
				
            			return false;
                });
        });
        &lt;/script&gt;

where i need to combare with the database before posting it to the url php page how can i do it if any body know it please solve this


  1. 0-9,/,\,=,+,;,: ↩︎

In your joinnick.php file, print some message/key/flag:


if(nic_exists){
    echo 'Yes';
}
else{
    echo 'No';
}

And your javascript should be something like this:


		$(function() {
			$(".submnick").click(function() {
				var nick 		= $("#nick").val();
				var dataString1 = 'nick=' + nick;
				var hello 		= nick.length;
				var jump 		= '^[0-9,/,\\,=,+,;,:]*$';
				if(hello <= 3) {
					$('.successan').fadeOut(200).hide();
					$('.erroran').fadeOut(200).show();
				}	
				else if(nick == !nick.match(jump)){
					$('.successan').fadeOut(200).hide();
					$('.erroran').fadeOut(200).show();
				}
				else {
					$.post("joinnick.php", {nick:nick}, function(data){
						if(data == 'Yes'){
							// that means username already exits in the 
							// write an error message to an element
						}
						else{
							// otherwise the nickname does not exist in the database
						}
					});
				}
				return false;
			});
		});

The ajax post line has been changed in new way of jquery ajax post.

Hope this will help you out.

thank you so much its working very nicely friend