0

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

4
Contributors
16
Replies
20
Views
7 Years
Discussion Span
Last Post by WebspoonUK
0
<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

0

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

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

That's it!

0

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

0
<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?

0
<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

0
<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

Edited by Reverend Jim: Fixed formatting

0
<!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>
0

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

0

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

0

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?

0

Is there any other javascript on the page?

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.