Jump to content

Help in JAva Script...


djbuddhi

Recommended Posts

Since an item can have a space in it, there isn't really a way to check if the user is moving on to the next item, so you can't check for the pipe there. You can check at the end before the form is submitted:

<html>
<head>
<script type="text/javascript">
function validate()
{
var str = document.getElementById("items");
if (str.value.match(/[\|]/g))
	str.form.submit();
else
	alert("no pipe");
}
</script>
</head>

<body>
<form>
<input id="items" type="text">
<button onclick="validate()">Submit</button>
</form>
</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/120808-help-in-java-script/#findComment-623054
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.