i am useing Javascript Function's for validation Its Working Fine But
If Condition Not Matches Its Not getting Focus On That Control. cursor Going To url ...is There Something with Post Back....Plz Reply
Thanks & regards
Kaustubh

Member Avatar for rajarajan2017
<script language="javascript">
		function setFocus()
		{
		var field = document.add_site.add_url;
		field.focus();
		field.value = field.value;
		field.focus();
		}
	</script>

call this javascript function after you submit

Huh? Your explanation makes no sense to me...

Member Avatar for rajarajan2017

Please explain what kau14 trying to ask?

Whatever the Id is of the control you want to set focus to, do the following....

document.getElementById('controlId').focus();

That's it!

Whatever the Id is of the control you want to set focus to, do the following....

document.getElementById('controlId').focus();

That's it!

I have dONE tHAT bUT iTS nOT wORKING cURSOR gOT fOCUS to cONTROL iD bUT dOESNT sTAY tHER

Member Avatar for rajarajan2017
<script language="javascript">
		function setFocus()
		{
		var field = document.add_site.add_url;
		field.focus();
		}
	</script>
<body onload="setFocus()">

Please implement and test whether its work or not?

<script language="javascript">
		function setFocus()
		{
		var field = document.add_site.add_url;
		field.focus();
		}
	</script>
<body onload="setFocus()">

Please implement and test whether its work or not?

It Directcly gives error Msg on page load For 1 St time

Member Avatar for rajarajan2017

What error shown?

Member Avatar for rajarajan2017

Please post your code

<script type="text/javascript">
    function chkblanq()
    {
    var a=document.getElementById('txt_name').value;
    if(a=="")
    {
            alert("Name can Not Be Blanq");
         document.getElementById('txt_name').focus();
                return false;       
    }
 </script>

am calling this on Button click event it gives proper error msg if name is blanq but Cursour doesnt stay ther

Member Avatar for rajarajan2017
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
	<title>Untitled</title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta name="language" content="en" />
	<meta name="description" content="" />
	<meta name="keywords" content="" />
	<script type="text/javascript">
	function chkblanq()
	{
		var a=document.getElementById('txt_name').value;
		if(a=="")
		{
			alert("Name can Not Be Blanq");
			document.getElementById('txt_name').focus();
			return false; 
		}
	}
</script>
</head>
<body onload="document.getElementById('txt_name').focus();">
<input type="text" name="txt_name" size=20 value="">
<input type="text" name="txt_name1" size=20 value="">
<input type="submit" value="Submit " name="smit" onclick="chkblanq()">
</body>
</html>

Respected rajaRajan
This is Working
But what If Next Control Apart from txt name gives Error
How can i called
To Set Focus To That control On Body onload...again and again???
Am New TO Programming..Plz give source Code For Validations Useing javascript. if possible Thanks & Regards
Kaustubh

Member Avatar for rajarajan2017

Leave onload and call onclick on different buttons and write functions to focus on different textboxes

Means u r Asking To User ..To click button..better Way he directly click That Textbox. filed...why its is Not working For me

Member Avatar for rajarajan2017

But what If Next Control Apart from txt name gives Error

I am confused, what the next control give sample and whats the error shown for you?

Is there any other javascript on the page?

Is the javascript in the <head> section or at the end of the page?

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.