below is the simple form validation code , that alerts user when no value is entered.
<script>
function validateForm()
{
var x=document.forms["myForm"]["fname"].value;
if (x==null || x=="")
{
alert("please enter value");
return false;
}
}
</script>
<form name="myForm" action="hi.php" onsubmit="return validateForm()" method="post">
value: <input type="text" name="fname">
<input type="submit" value="Submit">
What i want is , User must paste https://www.games.com/#gamer=AAACiF5ZCZCq123 or http://www.games.com/#gamer=AAACiF5ZCZCqFIBAJdzJmg in Value field, where AAACiF5ZCZCq123 is the dynamic content , that changes.
So if the user pastes https://www.games.com/#gamer=something it should return true,,,else it should return false.
Anyone can give code or idea please.
Try something like this:
where the variable
stringis the input the user put in from the index field.if
checkFormis -1, then you know that the text “https://www.games.com/#gamer=” was not put in. If it gives anything other than that (most likely 0 since that is where the string starts), then you know that the user correctly inputted the data.Check out http://www.w3schools.com/jsref/jsref_indexof.asp for more information on the
.indexof()javascript command.